?? lab04.m
字號(hào):
function varargout = lab04(varargin)
% LAB04 M-file for lab04.fig
% LAB04, by itself, creates a new LAB04 or raises the existing
% singleton*.
%
% H = LAB04 returns the handle to a new LAB04 or the handle to
% the existing singleton*.
%
% LAB04('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in LAB04.M with the given input arguments.
%
% LAB04('Property','Value',...) creates a new LAB04 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before lab04_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to lab04_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 lab04
% Last Modified by GUIDE v2.5 25-May-2005 13:52:01
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @lab04_OpeningFcn, ...
'gui_OutputFcn', @lab04_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 lab04 is made visible.
function lab04_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 lab04 (see VARARGIN)
% Choose default command line output for lab04
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes lab04 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
%設(shè)置當(dāng)前窗口名
str='180度根軌跡實(shí)驗(yàn)窗口';
set(gcf,'name',str,'numbertitle','off');
% --- Outputs from this function are returned to the command line.
function varargout = lab04_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 during object creation, after setting all properties.function edit_a_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_a (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'));endfunction edit_a_Callback(hObject, eventdata, handles)% hObject handle to edit_a (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 edit_a as text% str2double(get(hObject,'String')) returns contents of edit_a as a double% --- Executes during object creation, after setting all properties.function edit_b_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_b (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'));endfunction edit_b_Callback(hObject, eventdata, handles)% hObject handle to edit_b (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 edit_b as text% str2double(get(hObject,'String')) returns contents of edit_b as a double% --- Executes during object creation, after setting all properties.function edit_c_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_c (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'));endfunction edit_c_Callback(hObject, eventdata, handles)% hObject handle to edit_c (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 edit_c as text% str2double(get(hObject,'String')) returns contents of edit_c as a double% --- Executes during object creation, after setting all properties.function edit_d_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_d (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'));endfunction edit_d_Callback(hObject, eventdata, handles)% hObject handle to edit_d (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 edit_d as text% str2double(get(hObject,'String')) returns contents of edit_d as a double% --- Executes on button press in pushbutton_sure.function pushbutton_sure_Callback(hObject, eventdata, handles)% hObject handle to pushbutton_sure (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)
%接受編輯框中的A,B,C,D的值并畫根軌跡圖A=str2num(get(handles.edit_a,'string'))
B=str2num(get(handles.edit_b,'string'))C=str2num(get(handles.edit_c,'string'))
D=str2num(get(handles.edit_d,'string'))
sys=ss(A,B,C,D)
subplot('Position',[0.06,0.257,0.355,0.422])
rlocus(sys)
%得出當(dāng)系統(tǒng)穩(wěn)定時(shí)的K的取值范圍
newsys=zpk(sys)
z=zero(newsys)
p=pole(newsys)
num=poly(z)
den=poly(p)
syms('x','w','k','real')
n=poly2sym(k*num,x)
d=poly2sym(den,x)
f=n+d
g=w*i
h=compose(f,g)
r=real(h)
l=simplify(imag(h))
[k,w]=solve(r,l)
k1=sym2poly(k)
if min(k1)<0
set(handles.edit_stastic,'string',0)
else
set(handles.edit_stastic,'string',min(k1))
end
if max(k1)<=0
set(handles.edit_stastic1,'string',inf)
else
set(handles.edit_stastic1,'string',max(k1))
end
% --- Executes on button press in pushbutton_quit.function pushbutton_quit_Callback(hObject, eventdata, handles)% hObject handle to pushbutton_quit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)
%設(shè)置關(guān)閉窗口提示對(duì)話框button=questdlg('Do you want to close this window?',...
'Close Operation','Yes','No','No');
if strcmp(button,'Yes')
close
elseif strcmp(button,'No')
disp('Canceled file operation')
end
% --- Executes during object creation, after setting all properties.function edit_stastic_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_stastic (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'));endfunction edit_stastic_Callback(hObject, eventdata, handles)% hObject handle to edit_stastic (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 edit_stastic as text% str2double(get(hObject,'String')) returns contents of edit_stastic as a double% --- Executes during object creation, after setting all properties.function edit_stastic1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_stastic1 (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'));endfunction edit_stastic1_Callback(hObject, eventdata, handles)% hObject handle to edit_stastic1 (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 edit_stastic1 as text% str2double(get(hObject,'String')) returns contents of edit_stastic1 as a double
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -