📄 lab021.m
字号:
function varargout = lab021(varargin)
% LAB021 M-file for lab021.fig
% LAB021, by itself, creates a new LAB021 or raises the existing
% singleton*.
%
% H = LAB021 returns the handle to a new LAB021 or the handle to
% the existing singleton*.
%
% LAB021('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in LAB021.M with the given input arguments.
%
% LAB021('Property','Value',...) creates a new LAB021 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before lab021_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to lab021_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 lab021
% Last Modified by GUIDE v2.5 25-May-2005 16:59:57
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @lab021_OpeningFcn, ...
'gui_OutputFcn', @lab021_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 lab021 is made visible.
function lab021_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 lab021 (see VARARGIN)
% Choose default command line output for lab021
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes lab021 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
%设置当前窗口名
str='参量根轨迹实验窗口';
set(gcf,'name',str,'numbertitle','off');
% --- Outputs from this function are returned to the command line.
function varargout = lab021_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 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)% --- 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)
%设置关闭窗口提示对话框button=questdlg('Do you want to quit?',...
'Quit 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 slider1_CreateFcn(hObject, eventdata, handles)% hObject handle to slider1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background, change% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on slider movement.function slider1_Callback(hObject, eventdata, handles)% hObject handle to slider1 (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,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
%绘制随T值变化的根轨迹图set(handles.edit_t,'string',num2str(get(handles.slider1,'value')));
val1=str2num(get(handles.edit_t,'string'))
t=str2num(get(handles.edit_t,'string'))
if isnumeric(val1)&length(val1)==1&...
val1>=get(handles.slider1,'Min')&...
val1<=get(handles.slider1,'Max')
set(handles.slider1,'Value',val1);
else handles.numberofErrors=handles.numberofErrors+1;
set(handles.edit_t,'String',...
[handles.errorString,num2str(handle.numberofErrors)]);
guidata(gcbo,handle);
end
num=[1];
den=[t t+1 1 0];
sys=tf(num,den)
subplot('Position',[0.123,0.257,0.355,0.422])
rlocus(sys)
%得出当系统稳定时K的取值范围
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_stastic2,'string',inf)
else
set(handles.edit_stastic2,'string',max(k1))
end
% --- Executes during object creation, after setting all properties.function edit_t_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_t (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_t_Callback(hObject, eventdata, handles)% hObject handle to edit_t (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_t as text% str2double(get(hObject,'String')) returns contents of edit_t as a double% --- Executes during object creation, after setting all properties.function edit_k_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_k (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_k_Callback(hObject, eventdata, handles)% hObject handle to edit_k (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_k as text% str2double(get(hObject,'String')) returns contents of edit_k as a double% --- Executes during object creation, after setting all properties.function slider_k_CreateFcn(hObject, eventdata, handles)% hObject handle to slider_k (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background, change% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes during object creation, after setting all properties.function analyze_Callback(hObject, eventdata, handles)% hObject handle to analyze (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)
analyze1% --- Executes during object creation, after setting all properties.function edit_stastic2_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_stastic2 (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_stastic2_Callback(hObject, eventdata, handles)% hObject handle to edit_stastic2 (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_stastic2 as text% str2double(get(hObject,'String')) returns contents of edit_stastic2 as a double
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -