📄 lab42.m
字号:
function [ret,x0,str,ts,xts]=lab42(t,x,u,flag);
%LAB42 is the M-file description of the SIMULINK system named LAB42.
% The block-diagram can be displayed by typing: LAB42.
%
% SYS=LAB42(T,X,U,FLAG) returns depending on FLAG certain
% system values given time point, T, current state vector, X,
% and input vector, U.
% FLAG is used to indicate the type of output to be returned in SYS.
%
% Setting FLAG=1 causes LAB42 to return state derivatives, FLAG=2
% discrete states, FLAG=3 system outputs and FLAG=4 next sample
% time. For more information and other options see SFUNC.
%
% Calling LAB42 with a FLAG of zero:
% [SIZES]=LAB42([],[],[],0), returns a vector, SIZES, which
% contains the sizes of the state vector and other parameters.
% SIZES(1) number of states
% SIZES(2) number of discrete states
% SIZES(3) number of outputs
% SIZES(4) number of inputs
% SIZES(5) number of roots (currently unsupported)
% SIZES(6) direct feedthrough flag
% SIZES(7) number of sample times
%
% For the definition of other parameters in SIZES, see SFUNC.
% See also, TRIM, LINMOD, LINSIM, EULER, RK23, RK45, ADAMS, GEAR.
% Note: This M-file is only used for saving graphical information;
% after the model is loaded into memory an internal model
% representation is used.
% the system will take on the name of this mfile:
sys = mfilename;
new_system(sys)
simver(1.3)
if (0 == (nargin + nargout))
set_param(sys,'Location',[133,199,567,499])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-45')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '50')
set_param(sys,'Min step size', '0.0001')
set_param(sys,'Max step size', '10')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
add_block('built-in/Step Fcn',[sys,'/','阶跃函数'])
set_param([sys,'/','阶跃函数'],...
'Font Size',11,...
'Time','0',...
'position',[30,110,50,130])
add_block('built-in/Sum',[sys,'/','加法器'])
set_param([sys,'/','加法器'],...
'Font Size',11,...
'inputs','+-',...
'position',[110,115,130,135])
add_block('built-in/Transfer Fcn',[sys,'/','被控对象'])
set_param([sys,'/','被控对象'],...
'Font Size',11,...
'Numerator','N',...
'Denominator','D',...
'position',[195,110,255,140])
add_block('built-in/Scope',[sys,'/','示波器'])
set_param([sys,'/','示波器'],...
'Font Size',11,...
'Vgain','3.000000',...
'Hgain','50.000000',...
'Vmax','6.000000',...
'Hmax','100.000000',...
'Window',[588,234,789,384])
open_system([sys,'/','示波器'])
set_param([sys,'/','示波器'],...
'Mask Display','',...
'position',[385,112,405,138])
% Subsystem ['Double click here',13,'to start loading data',13,'and mu-syn design'].
new_system([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design']])
set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design']],'Location',[2,439,106,512])
set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design']],...
'Mask Display','初始化',...
'Mask Dialogue','eval(''clc;clear all;N=[28 28];D=[1 3 12 -16 0];printsys(N,D);'')')
% Finished composite block ['Double click here',13,'to start loading data',13,'and mu-syn design'].
set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design']],...
'ForeGround',4,...
'hide name',0,...
'Drop Shadow',4,...
'position',[110,215,175,247])
add_block('built-in/Note',[sys,'/','根轨迹实验窗口'])
set_param([sys,'/','根轨迹实验窗口'],...
'ForeGround',4,...
'Font Size',16,...
'position',[215,40,220,45])
% Subsystem ['Double click here',13,'to show bode plot ',13,'of controller1'].
new_system([sys,'/',['Double click here',13,'to show bode plot ',13,'of controller1']])
set_param([sys,'/',['Double click here',13,'to show bode plot ',13,'of controller1']],'Location',[2,439,106,512])
set_param([sys,'/',['Double click here',13,'to show bode plot ',13,'of controller1']],...
'Mask Display','根轨迹图')
set_param([sys,'/',['Double click here',13,'to show bode plot ',13,'of controller1']],...
'Mask Dialogue','eval(''figure;rloc1(N,D);grid on;set(gcf,''''name'''',''''根轨迹图'''');title(''''系统根轨迹图'''');xlabel(''''实 轴'''');ylabel(''''虚 轴'''');'')')
% Finished composite block ['Double click here',13,'to show bode plot ',13,'of controller1'].
set_param([sys,'/',['Double click here',13,'to show bode plot ',13,'of controller1']],...
'ForeGround',4,...
'hide name',0,...
'Drop Shadow',4,...
'position',[245,215,310,245])
add_line(sys,[260,125;380,125])
add_line(sys,[55,120;105,120])
add_line(sys,[260,125;350,125;350,180;80,180;80,130;105,130])
add_line(sys,[135,125;190,125])
drawnow
% Return any arguments.
if (nargin | nargout)
% Must use feval here to access system in memory
if (nargin > 3)
if (flag == 0)
eval(['[ret,x0,str,ts,xts]=',sys,'(t,x,u,flag);'])
else
eval(['ret =', sys,'(t,x,u,flag);'])
end
else
[ret,x0,str,ts,xts] = feval(sys);
end
else
drawnow % Flash up the model and execute load callback
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -