📄 c2ex20.m
字号:
function [ret,x0,str,ts,xts]=c2ex22(t,x,u,flag);%C2EX22 is the M-file description of the SIMULINK system named C2EX22.% The block-diagram can be displayed by typing: C2EX22.%% SYS=C2EX22(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 C2EX22 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 C2EX22 with a FLAG of zero:% [SIZES]=C2EX22([],[],[],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',[143,109,643,409]) open_system(sys)end;set_param(sys,'algorithm', 'RK-45')set_param(sys,'Start time', '0.0')set_param(sys,'Stop time', '72')set_param(sys,'Min step size', '0.001')set_param(sys,'Max step size', '10')set_param(sys,'Relative error','1e-3')set_param(sys,'Return vars', '[t,x,vo]')add_block('built-in/Step Fcn',[sys,'/','Step Input'])set_param([sys,'/','Step Input'],... 'Time','0',... 'After','0.556',... 'position',[15,70,35,90])add_block('built-in/Integrator',[sys,'/','Integrator1'])set_param([sys,'/','Integrator1'],... 'position',[70,70,90,90])add_block('built-in/Gain',[sys,'/','10//RC'])set_param([sys,'/','10//RC'],... 'Gain','27.8',... 'position',[305,72,330,98])add_block('built-in/Integrator',[sys,'/','Integrator2'])set_param([sys,'/','Integrator2'],... 'position',[245,75,265,95])add_block('built-in/Sum',[sys,'/','Sum'])set_param([sys,'/','Sum'],... 'inputs','+-',... 'position',[195,75,215,95])add_block('built-in/Gain',[sys,'/','M//B'])set_param([sys,'/','M//B'],... 'Gain','.00002',... 'position',[130,67,155,93])add_block('built-in/Gain',[sys,'/','Gain'])set_param([sys,'/','Gain'],... 'Gain','-1',... 'position',[345,72,370,98])add_block('built-in/To Workspace',[sys,'/','To Workspace'])set_param([sys,'/','To Workspace'],... 'mat-name','vo',... 'position',[440,77,490,93])add_block('built-in/Integrator',[sys,'/','Integrator3'])set_param([sys,'/','Integrator3'],... 'position',[385,75,405,95])add_block('built-in/Gain',[sys,'/','K//B'])set_param([sys,'/','K//B'],... 'orientation',2,... 'Gain','.08',... 'position',[225,187,250,213])add_block('built-in/Scope',[sys,'/','Scope1'])set_param([sys,'/','Scope1'],... 'Vgain','40.000000',... 'Hgain','72.000000',... 'Vmax','80.000000',... 'Hmax','144.000000',... 'Window',[71,241,270,359],... 'position',[130,180,160,210])add_block('built-in/Scope',[sys,'/','Scope'])set_param([sys,'/','Scope'],... 'Vgain','10.000000',... 'Hgain','72.000000',... 'Vmax','20.000000',... 'Hmax','144.000000',... 'Window',[112,160,443,474])open_system([sys,'/','Scope'])set_param([sys,'/','Scope'],... 'position',[445,175,475,205])add_line(sys,[160,80;190,80])add_line(sys,[335,85;340,85])add_line(sys,[375,85;380,85])add_line(sys,[40,80;65,80])add_line(sys,[95,80;125,80])add_line(sys,[220,85;240,85])add_line(sys,[270,85;300,85])add_line(sys,[110,80;110,195;125,195])add_line(sys,[220,200;170,200;170,90;190,90])add_line(sys,[285,85;285,200;255,200])add_line(sys,[410,85;435,85])add_line(sys,[420,85;420,190;440,190])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); endelse drawnow % Flash up the model and execute load callbackend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -