function varargout = exp3(varargin)
% EXP3 M-file for exp3.fig
% EXP3, by itself, creates a new EXP3 or raises the existing
% singleton*.
%
% H = EXP3 returns the handle to a new EXP3 or the handle to
% the existing singleton*.
%
% EXP3('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in EXP3.M with the given input arguments.
%
% EXP3('Property','Value',...) creates a new EXP3 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before exp3_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to exp3_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help exp3
% Last Modified by GUIDE v2.5 14-May-2009 15:13:05
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @exp3_OpeningFcn, ...
'gui_OutputFcn', @exp3_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before exp3 is made visible.
function exp3_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to exp3 (see VARARGIN)
% Choose default command line output for exp3
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes exp3 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = exp3_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function R_Callback(hObject, eventdata, handles)
function R_CreateFcn(hObject, eventdata, handles)
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function L_Callback(hObject, eventdata, handles)
function L_CreateFcn(hObject, eventdata, handles)
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function C_Callback(hObject, eventdata, handles)
function C_CreateFcn(hObject, eventdata, handles)
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function state_Callback(hObject, eventdata, handles)
function state_CreateFcn(hObject, eventdata, handles)
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function pushbutton1_Callback(hObject, eventdata, handles)
r = str2double(get(handles.R,'String'));
l = str2double(get(handles.L,'String'));
c = str2double(get(handles.C,'String'));
A=[-r/l,-1/l;1/c,0];
B=[1/l;0];
C=[1,0;0,1];
sys=ss(A,B,C,0);
t=(0:0.01:15);
y=step(sys,t);
if r==0
set(handles.state,'string','无阻尼');
else if r==2*sqrt(l/c)
set(handles.state,'string','临界阻尼');
else if r>2*sqrt(l/c)
set(handles.state,'string','过阻尼');
else if r<2*sqrt(l/c)
set(handles.state,'string','欠阻尼');
end
end
end
end
i=y(:,1);
v=y(:,2);
axes(handles.axes1)
plot(t,i)
grid on
title('t-i')
axes(handles.axes2)
plot(t,v)
grid on
title('t-v')
axes(handles.axes3)
plot(i,v)
grid on
title('i-v')
function pushbutton2_Callback(hObject, eventdata, handles)
r = str2double(get(handles.R,'String'));
l = str2double(get(handles.L,'String'));
c = str2double(get(handles.C,'String'));
A=[-r/l,-1/l;1/c,0];
B=[1/l;0];
C=[1,0;0,1];
sys=ss(A,B,C,0);
t=(0:0.01:15);
y=impulse(sys,t);
if r==0
set(handles.state,'string','无阻尼');
else if r==2*sqrt(l/c)
set(handles.state,'string','临界阻尼');
else if r>2*sqrt(l/c)
set(handles.state,'string','过阻尼');
else if r<2*sqrt(l/c)
set(handles.state,'string','欠阻尼');
end
end
end
end
i=y(:,1);
v=y(:,2);
axes(handles.axes1)
plot(t,i)
grid on
title('t-i')
axes(handles.axes2)
plot(t,v)
grid on
title('t-v')
axes(handles.axes3)
plot(i,v)
grid on
title('i-v')