function varargout = tresponse(varargin)
% TRESPONSE M-file for tresponse.fig
% TRESPONSE, by itself, creates a new TRESPONSE or raises the existing
% singleton*.
%
% H = TRESPONSE returns the handle to a new TRESPONSE or the handle to
% the existing singleton*.
%
% TRESPONSE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TRESPONSE.M with the given input arguments.
%
% TRESPONSE('Property','Value',...) creates a new TRESPONSE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before tresponse_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to tresponse_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help tresponse
% Last Modified by GUIDE v2.5 02-Jul-2007 12:05:33
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @tresponse_OpeningFcn, ...
'gui_OutputFcn', @tresponse_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 tresponse is made visible.
function tresponse_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 tresponse (see VARARGIN)
% Choose default command line output for tresponse
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes tresponse wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = tresponse_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;
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
r=get(handles.popupmenu1,'value');
num=get(handles.edit1,'string');
den=get(handles.edit2,'string');
num=str2num(num);
den=str2num(den);
if r==1
axes(handles.axes1);
T=0:0.1:10;
[Y t]=step(num,den,T);
cla
hold off
plot(T,Y);
elseif r==2
axes(handles.axes1);
t=0:0.1:10;
[y T]=impulse(num,den,t);
hold off
cla
plot(t,y)
elseif r==3
axes(handles.axes1);
t=0:0.1:10;
input=t;
[y T]=lsim(num,den,input,t);
hold off
cla
plot(t,y)
elseif r==4
axes(handles.axes1);
[pol zer]=pzmap(num,den);
hold off
cla
plot(pol,'x');
hold on
plot(zer,'o');
hold off
elseif r==5
axes(handles.axes1);
[R K]=rlocus(num,den);
hold off
cla
plot(R)
elseif r==6
axes(handles.axes1);
w=0.1:0.1:10;
[Mag Ph]=bode(num,den,w);
hold off
cla
semilogx(w,Mag)
end
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% rb1=get(handles.radiobutton1,'string') ;
% rb2=get(handles.radiobutton2,'string');
% if rb1=='on'
% axes(handles.axes1)
% grid on
% elseif rb2=='on'
% axes(handles.axes1)
% grid off
% end
% --- Executes on button press in radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton3
set(handles.radiobutton4,'value',0)
stat=get(handles.radiobutton3,'value');
if stat==1
grid off
else
grid on
end
% --- Executes on button press in radiobutton4.
function radiobutton4_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton4
set(handles.radiobutton3,'value',0)
stat=get(handles.radiobutton4,'value');
if stat==1
grid on
else
grid off
end