function varargout = BodePlotGui(varargin)
% BODEPLOTGUI Application M-file for BodePlotGui.fig
% FIG = BODEPLOTGUI launch BodePlotGui GUI.
% BODEPLOTGUI('callback_name', ...) invoke the named callback.
% Last Modified by GUIDE v2.5 18-Oct-2011 14:11:08
%Written by Erik Cheever (Copyright 2002)
%Contact: erik_cheever@swarthmore.edu
% Erik Cheever
% Dept. of Engineering
% Swarthmore College
% 500 College Avenue
% Swarthmore, PA 19081 USA
%This function acts as a switchyard for several callbacks. It also intializes
%the variables used by the GUI. Note that all variables are initialized here to
%default values. A brief description of each variable is included.
if (nargin == 0) || (isa(varargin{1},'tf')) %If no arguments, or first
fig = openfig(mfilename,'new');
handles = guihandles(fig); %Get handles structure.
initBodePlotGui(handles);
handles=guidata(handles.AsymBodePlot); %Reload handles after function call.
if nargout > 0 %If output argument is used, set it to figure.
varargout{1} = fig;
end
if ((nargin~=0) && (isa(varargin{1},'tf'))),
%Transfer function chosen.
handles.Sys=varargin{1}; %The variable Sys is the transfer function.
doBodeGUI(handles);
end
elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK
try
[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
catch
disp(lasterr);
end
end
end
% ------------------End of function BodePlotGui ----------------------
function initBodePlotGui(handles)
handles.IncludeString=[]; %An array of strings representing terms to include in the plot.
handles.ExcludeString=[]; %An array of strings representing terms to exclude from plot.
handles.IncElem=[]; %An array of indices of terms corresponding to their
% location in the IncludeString array.
handles.ExcElem=[]; %An array of indices of terms corresponding to their
% location in the ExcludeString array.
handles.FirstPlot=1; %This term is 1 the first time a plot is made. This lets
% Matlab do the original autoscaling. The scales are then
% saved and reused.
handles.MagLims=[]; %The limits on the magnitude plot determined by MatLab autoscaling.
handles.PhaseLims=[]; %The limits on the phase plot determined by MatLab autoscaling.
handles.LnWdth=2;
set(handles.LineWidth,'String',num2str(handles.LnWdth));
%Set the color of lines used in gray scale. The plotting functions
%cycle through these colors (and then cycle through the linestyles).
handles.Gray=[0.75 0.75 0.75; 0.5 0.5 0.5; 0.25 0.25 0.25];
handles.GrayZero=[0.9 0.9 0.9]; %This is the color used for the zero reference.
%Set the color of lines used in color plots. The plotting functions
%cycle through these colors (and then cycle through the linestyles).
handles.Color=[0 1 1; 0 0 1; 0 1 0; 1 0 0; 1 0 1;1 0.52 0.40];
handles.ColorZero=[1 1 0]; %Yellow, this is the color used for the zero reference.
%Sets order of linestyles used.
handles.linestyle={':','--','-.'};
%This sets the default scheme to color (GUI can set them to gray scale).
handles.colors=handles.Color;
handles.zrefColor=handles.ColorZero;
handles.exactColor=[0 0 0]; %Black
handles.Sys=[];
handles.SysInc=[];
handles.Terms=[];
%The structure "Term" has three elements.
% type: this can be any of the 7 types listed below.
% 1) The multiplicative constant.
% 2) Real poles
% 3) Real zeros
% 4) Complex poles
% 5) Complex zeros
% 6) Poles at the origin
% 7) Zeros at the origin
% value: this is the location of the pole or zero (or in the case
% of the multiplicative constant, its value).
% multiplicity: this gives the multiplicity of the pole or zero. It has
% no meaning in the case of the multiplicative constant.
%The variable "Acc" is a relative accuracy used to determine whether or not
%two poles (or zeros) are the same. Because Matlab uses an approximate
%technique to find roots of an equation, it is likely to give slightly
%different locations to identical roots.
handles.Acc=1E-3;
set(handles.TransferFunctionText,'String',...
{' ','No transfer function chosen',' '});
guidata(handles.AsymBodePlot, handles); %save changes to handles.
loadSystems(handles);
handles=guidata(handles.AsymBodePlot); %Reload handles after function call.
guidata(handles.AsymBodePlot, handles); %save changes to handles.
end
function simpleTF = makeSimple(origTF)
simpleTF=minreal(origTF); %Get minimum realization.
% Get numerator and denominator of two realizations. If their
% lengths are unequal, it means that there were poles and zeros that
% cancelled.
[n1,d1]=tfdata(simpleTF,'v');
[n2,d2]=tfdata(origTF,'v');
if (length(n1)~=length(n2)),
disp(' ');
disp(' ');
disp(' ');
disp('************Warning******************');
disp('Original transfer function was:');
origTF
disp('Some poles and zeros were equal. After cancellation:');
simpleTF
disp('The simplified transfer function is the one that will be used.');
disp('*************************************');
disp(' ');
beep;
waitfor(warndlg('System has poles and zeros that cancel. See Command Window for caveats.'));
end
end
function doBodeGUI(handles)
handles.Sys=makeSimple(handles.Sys);
handles.SysInc=handles.Sys; %The variable sysInc is that part of the transfer
% function that will be plotted (with no poles or zeros excluded). Start with
% it equal to Sys. This variable is modified in BodePlotSys
%The function BodePlotTerms separates the transfer function into its consituent parts.
% The variable DoQuit will come back as non-zero if there was a problem.
DoQuit=BodePlotTerms(handles);
handles=guidata(handles.AsymBodePlot); %Reload handles after function call.
%if DoQuit is zero, there were no problems and we may continue.
if ~DoQuit,
BodePlotter(handles); %Make plot
handles=guidata(handles.AsymBodePlot); %Reload handles after function call.
%DoQuit was non-zero, so there was a problem. Quit program.
else
CloseButton_Callback(fig,'',handles,'');
end
end
%| ABOUT CALLBACKS:
%| GUIDE automatically appends subfunction prototypes to this file, and
%| sets objects' callback properties to call them through the FEVAL
%| switchyard above. This comment describes that mechanism.
%|
%| Each callback subfunction declaration has the following form:
%| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN)
%|
%| The subfunction name is composed using the object's Tag and the
%| callback type separated by '_', e.g. 'slider2_Callback',
%| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'.
%|
%| H is the callback object's handle (obtained using GCBO).
%|
%| EVENTDATA is empty, but reserved for future use.
%|
%| HANDLES is a structure containing handles of components in GUI using
%| tags as fieldnames, e.g. handles.figure1, handles.slider2. This
%| structure is created at GUI startup using GUIHANDLES and stored in
%| the figure's application data using GUIDATA. A copy of the structure
%| is passed to each callback. You can store additional information in
%| this structure at GUI startup, and you can change the structure
%| during callbacks. Call guidata(h, handles) after changing your
%| copy to replace the stored original so that subsequent callbacks see
%| the updates. Type "help guihandles" and "help guidata" for more
%| information.
%|
%| VARARGIN contains any extra arguments you have passed to the
%| callback. Specify the extra arguments by editing the callback
%| property in the inspector. By default, GUIDE sets the property to:
%| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo))
%| Add any extra arguments after the last argument, before the final
%| closing parenthesis.
% -----------------------------------------------------
BodePlotGui.zip_MATLAB GUI bode_bode_bode GUI_bode plot _gui bo
版权申诉
192 浏览量
2022-07-14
04:37:13
上传
评论
收藏 26KB ZIP 举报
林当时
- 粉丝: 95
- 资源: 1万+
最新资源
- mybatis中的动态sql, 涉及 where trim set if foreach等
- 简单- 快递运输(Java & JS & Python & C).html
- mybatis框架 更改ems系统,使用动态sql等.zip
- 易语言工具条下拉菜单实现
- Mybatis动态SQL高级映射.zip
- 源码esp8266开发板机智云机智云智能灯
- Python实现多图像转换成连贯的PDF文件,支持所有图片格式,可预览、裁剪、自定义PDF布局、设置图像顺序、PDF质量选择等
- H5腾讯地图选择位置组件
- 基于UCC28019+LM5017电源板硬件(原理图+PCB)工程文件.zip
- 源码esp8266开发板机智云机智云空气净化器
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0