⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 envgui.m

📁 这是一个PID自动调节的程序
💻 M
📖 第 1 页 / 共 2 页
字号:
      tau = str2num(get_param('autotunerPID/Plant/Transport Delay','DelayTime'));
   catch
      msgbox('The Bode diagrams can be computed only for linear models',...
         'AutotunerPID','error');
      return
   end
   bodePIDcompare(num,den,tau);
else
   msgbox('The simulation must be STOPPED to perform the Comparative Analysis',...
         'AutotunerPID','warn');
end

% end LocalBodePID


%=============================================================================
% LocalHlp
% The callback function for Help
%=============================================================================
function LocalHlp
web([strrep(which('envgui'),'envgui.m','') 'help/index_doc.html'],'-browser')
% end LocalHlp


%=============================================================================
% LocalEnvSets
% Local function to set the position of the graphics objects in the Env GUI
% animation window.
%=============================================================================
function LocalEnvSets(time,ud,u)
global AUTOTUNE
global ENVINACTIVE

if AUTOTUNE
   set(ud.Noise,'Enable','off');
   set(ud.NoiseVar,'Enable','off');
   set(ud.LoadDist,'Enable','off');
   set(ud.LoadAmp,'Enable','off');
   ENVINACTIVE = 1;
elseif ~AUTOTUNE & ENVINACTIVE
   % Autotuning process completed (update parameters and set the GUI
   % active)
   set(ud.Noise,'Enable','on');
   set(ud.NoiseVar,'Enable','on');
   set(ud.LoadDist,'Enable','on');
   set(ud.LoadAmp,'Enable','on');
   ENVINACTIVE = 0;
end

% Force plot to be drawn
pause(0), drawnow
% end LocalEnvSets


%=============================================================================
% LocalEnvInit
% Local function to initialize the Env GUI animation.  If the animation
% window already exists, it is brought to the front.  Otherwise, a new
% figure window is created.
%=============================================================================
function LocalEnvInit(NoiseBlock,LoadDistBlock)
% The name of the reference is derived from the name of the
% subsystem block that owns the GUI S-function block.
% This subsystem is the current system and is assumed to be the same
% layer at which the reference block resides.
sys = get_param(gcs,'Parent');

global AUTOTUNE
global AUTOMAN
global INACTIVE


% The animation figure handle is stored in the GUI block's UserData.
% If it exists, initialize all the fields
Fig = get_param(gcbh,'UserData');
if ishandle(Fig),
   FigUD = get(Fig,'UserData');
   
   set(FigUD.Noise,...
      'Value',0,...
      'Enable','on');
   set(FigUD.NoiseVar,...
      'String','0.0001',...
      'Enable','on');
   set(FigUD.LoadDist,...
      'Value',0,...
      'Enable','on');
   set(FigUD.LoadAmp,...
      'String','1',...
      'Enable','on');
   
   % bring it to the front
   figure(Fig);
   return
end

% the animation figure doesn't exist, create a new one and store its
% handle in the animation block's UserData
FigureName = 'Environment Panel';

% Figure
FigH = 150;                % figure height
FigW = 272;                % figure width
Fig = figure(...
   'Units',              'pixel',...
   'Position',           [100 300-FigH FigW FigH],...
   'Name',               FigureName,...
   'NumberTitle',        'off',...
   'IntegerHandle',      'off',...
   'HandleVisibility',   'callback',...
   'MenuBar',            'none',...
   'Resize',				 'off',...
   'DoubleBuffer',       'on',...
   'DeleteFcn',          'envgui([],[],[],''DeleteFigure'')',...
   'CloseRequestFcn',    'envgui([],[],[],''Close'');');

% operating condition
uicontrol(...
   'Parent',             Fig,...
   'Style',              'text',...
   'Units',              'pixel',...
   'Position',           [12 FigH-19 140 14], ...
   'HorizontalAlignment','left',...
   'Fontweight',         'bold',...
   'Backgroundcolor',    [0.8 0.8 0.8],...
   'String',             'Operating Conditions');
uicontrol(...
   'Parent',             Fig,...
   'Style',              'frame',...
   'Units',              'pixel',...
   'Position',           [12 FigH-64 248 44]);
Noise = uicontrol(...
   'Parent',             Fig,...
   'Style',              'checkbox',...
   'Position',           [16 FigH-42 140 18],...
   'String',             'Measurement noise',...
   'Fontweight',         'bold',...
   'Value',              0,...
   'Callback',           'envgui([],[],[],''Noise'');');
uicontrol(...
   'Parent',             Fig,...
   'Style',              'text',...
   'Units',              'pixel',...
   'Position',           [156 FigH-40 40 14], ...
   'HorizontalAlignment','right',...
   'Fontweight',         'bold',...
   'String',             'var. ');
NoiseVar = uicontrol(...
   'Parent',             Fig,...
   'Style',              'edit',...
   'Units',              'pixel',...
   'Position',           [196 FigH-42 60 18], ...
   'HorizontalAlignment','center',...
   'String',             '0.0001',...
   'Backgroundcolor',    [1 1 1],...
   'Callback',           'envgui([],[],[],''NoiseParam'');');
LoadDist = uicontrol(...
   'Parent',             Fig,...
   'Style',              'checkbox',...
   'Position',           [16 FigH-62 150 18],...
   'String',             'Load disturbance',...
   'Fontweight',         'bold',...
   'Value',              0,...
   'Callback',           'envgui([],[],[],''Dist'');');
uicontrol(...
   'Parent',             Fig,...
   'Style',              'text',...
   'Units',              'pixel',...
   'Position',           [166 FigH-60 30 14], ...
   'HorizontalAlignment','right',...
   'Fontweight',         'bold',...
   'String',             'amp. ');
LoadAmp = uicontrol(...
   'Parent',             Fig,...
   'Style',              'edit',...
   'Units',              'pixel',...
   'Position',           [196 FigH-60 60 18], ...
   'HorizontalAlignment','center',...
   'String',             '1',...
   'Backgroundcolor',    [1 1 1],...
   'Callback',           'envgui([],[],[],''DistParam'');');

% compact analysis
uicontrol(...
   'Parent',             Fig,...
   'Style',              'text',...
   'Units',              'pixel',...
   'Position',           [12 FigH-88 240 14], ...
   'HorizontalAlignment','left',...
   'Fontweight',         'bold',...
   'FontSize',           8,...
   'Backgroundcolor',    [0.8 0.8 0.8],...
   'String',             'Comparative Analysis');
uicontrol(...
   'Parent',             Fig,...
   'Style',              'frame',...
   'Units',              'pixel',...
   'Position',           [12 FigH-118 248 28]);
uicontrol(...
   'Parent',             Fig,...
   'Style',              'pushbutton',...
   'Position',           [22 FigH-114 72 20],...
   'String',             'Time', ...
   'Fontweight',         'bold',...
   'Callback',           'envgui([],[],[],''StepPID'');');
uicontrol(...
   'Parent',             Fig,...
   'Style',              'pushbutton',...
   'Position',           [176 FigH-114 72 20],...
   'String',             'Frequency', ...
   'Fontweight',         'bold',...
   'Callback',           'envgui([],[],[],''BodePID'');');
% help button
uicontrol(...
   'Parent',             Fig,...
   'Style',              'pushbutton',...
   'Position',           [100 FigH-145 72 20],...
   'String',             'Help', ...
   'Fontweight',         'bold',...
   'Callback',           'envgui([],[],[],''Hlp'');');


% all the HG objects are created, store them into the Figure's UserData

% operating conditions
FigUD.Noise        = Noise;
FigUD.NoiseVar     = NoiseVar;
FigUD.LoadDist     = LoadDist;
FigUD.LoadAmp      = LoadAmp;
% Simulink Block Interaction
FigUD.Block        = get_param(gcbh,'Handle');
FigUD.NoiseBlock   = get_param([sys '/' NoiseBlock],'Handle');
FigUD.LoadDistBlock= get_param([sys '/' LoadDistBlock],'Handle');

set(Fig,'UserData',FigUD);

drawnow

% store the figure handle in the animation block's UserData
set_param(gcbh,'UserData',Fig);
% end LocalEnvInit

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -