📄 expl5_13s.m
字号:
% Model for example 5.13 (Unstable plant and input constraints)
function [ret,x0,str,ts,xts]=Expl5_7s(t,x,u,flag);
% EXPL5_13 is the M-file description of the SIMULINK system named EXPL5_13S.
% The block-diagram can be displayed by typing: EXPL5_13S.
%
% SYS=EXPL5_7S(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 EXPL5_13S 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 EXPL5_7S with a FLAG of zero:
% [SIZES]=EXPL5_7S([],[],[],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.
% Copyright 1996-2003 Sigurd Skogestad & Ian Postlethwaite
% $Id: Expl5_13s.m,v 1.3 2004/02/05 12:23:14 vidaral Exp $
% the system will take on the name of this mfile:
sys = mfilename;
new_system(sys)
simver(3.0)
if (0 == (nargin + nargout))
set_param(sys,'Location',[169,79,824,558])
open_system(sys)
end;
set_param(sys,'Solver', 'ode15s')
set_param(sys,'StartTime', '0')
set_param(sys,'StopTime', '10')
% set_param(sys,'Min step size', '0.005')
set_param(sys,'MaxStep', '0.006')
set_param(sys,'RelTol','1e-3')
%set_param(sys,'Return vars', '')
add_block('built-in/Step Fcn',[sys,'/','Step Input'])
set_param([sys,'/','Step Input'],...
'Time','0',...
'After','0',...
'SampleTime','0',...
'position',[55,175,75,195])
add_block('built-in/Clock',[sys,'/','Clock'])
set_param([sys,'/','Clock'],...
'position',[55,45,75,65])
add_block('built-in/To Workspace',[sys,'/','To Workspace1'])
set_param([sys,'/','To Workspace1'],...
'mat-name','tout',...
'buffer','2000',...
'position',[565,47,615,63])
add_block('built-in/To Workspace',[sys,'/','To Workspace3'])
set_param([sys,'/','To Workspace3'],...
'mat-name','u2out',...
'buffer','2000',...
'position',[570,432,620,448])
add_block('built-in/To Workspace',[sys,'/','To Workspace4'])
set_param([sys,'/','To Workspace4'],...
'mat-name','y2out',...
'buffer','2000',...
'position',[570,357,620,373])
add_block('built-in/Step Fcn',[sys,'/','Step Input2'])
set_param([sys,'/','Step Input2'],...
'Time','0',...
'SampleTime','0',...
'After','0',...
'position',[55,355,75,375])
add_block('built-in/State-Space',[sys,'/','G1'])
set_param([sys,'/','G1'],...
'A','Ag',...
'B','Bg',...
'C','Cg',...
'D','Dg',...
'position',[385,349,460,391])
add_block('built-in/Sum',[sys,'/','Sum3'])
set_param([sys,'/','Sum3'],...
'position',[485,355,505,375])
add_block('built-in/State-Space',[sys,'/','K1'])
set_param([sys,'/','K1'],...
'A','Ac',...
'B','Bc',...
'C','Cc',...
'D','Dc',...
'position',[220,349,295,391])
add_block('built-in/Sum',[sys,'/','Sum2'])
set_param([sys,'/','Sum2'],...
'inputs','+-',...
'position',[175,360,195,380])
add_block('built-in/Step Fcn',[sys,'/','Step disterbance'])
set_param([sys,'/','Step disterbance'],...
'SampleTime','0',...
'position',[55,290,75,310])
add_block('built-in/State-Space',[sys,'/','Gd1'])
set_param([sys,'/','Gd1'],...
'A','Ad',...
'B','Bd',...
'C','Cd',...
'D','Dd',...
'position',[385,279,460,321])
add_block('built-in/To Workspace',[sys,'/','To Workspace2'])
set_param([sys,'/','To Workspace2'],...
'mat-name','uout',...
'buffer','2000',...
'position',[565,252,615,268])
add_block('built-in/To Workspace',[sys,'/','To Workspace'])
set_param([sys,'/','To Workspace'],...
'mat-name','yout',...
'buffer','2000',...
'position',[565,177,615,193])
add_block('built-in/Sum',[sys,'/','Sum1'])
set_param([sys,'/','Sum1'],...
'position',[480,175,500,195])
add_block('built-in/Sum',[sys,'/','Sum'])
set_param([sys,'/','Sum'],...
'inputs','+-',...
'position',[170,180,190,200])
add_block('built-in/State-Space',[sys,'/','K'])
set_param([sys,'/','K'],...
'A','Ac',...
'B','Bc',...
'C','Cc',...
'D','Dc',...
'position',[215,169,290,211])
add_block('built-in/State-Space',[sys,'/','Gd'])
set_param([sys,'/','Gd'],...
'A','Ad',...
'B','Bd',...
'C','Cd',...
'D','Dd',...
'position',[380,104,455,146])
add_block('built-in/State-Space',[sys,'/','G'])
set_param([sys,'/','G'],...
'A','Ag',...
'B','Bg',...
'C','Cg',...
'D','Dg',...
'position',[380,169,455,211])
add_block('built-in/Saturation',[sys,'/','Saturation'])
set_param([sys,'/','Saturation'],...
'Lower Limit','-1',...
'Upper Limit','1',...
'position',[315,178,345,202])
add_block('built-in/Note',[sys,'/','System with Saturation'])
set_param([sys,'/','System with Saturation'],...
'position',[155,95,160,100])
add_block('built-in/Note',[sys,'/','System without Saturation'])
set_param([sys,'/','System without Saturation'],...
'position',[160,445,165,450])
add_line(sys,[295,190;310,190])
add_line(sys,[195,190;210,190])
add_line(sys,[80,185;165,185])
add_line(sys,[80,55;560,55])
add_line(sys,[350,190;350,260;560,260])
add_line(sys,[460,190;475,190])
add_line(sys,[460,125;465,125;475,180])
add_line(sys,[505,185;530,185;530,240;140,240;140,195;165,195])
add_line(sys,[505,185;560,185])
add_line(sys,[300,370;380,370])
add_line(sys,[200,370;215,370])
add_line(sys,[80,365;170,365])
add_line(sys,[465,370;480,370])
add_line(sys,[465,300;470,300;480,360])
add_line(sys,[510,365;535,365;535,420;135,420;135,375;170,375])
add_line(sys,[510,365;565,365])
add_line(sys,[80,300;380,300])
add_line(sys,[300,370;335,370;335,440;565,440])
add_line(sys,[350,190;375,190])
add_line(sys,[95,300;95,125;375,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 + -