📄 c2ex19.m
字号:
function [ret,x0,str,ts,xts]=ex2_20(t,x,u,flag);%EX2_20 is the M-file description of the SIMULINK system named EX2_20.% The block-diagram can be displayed by typing: c2ex19.%% SYS=EX2_20(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 EX2_20 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 EX2_20 with a FLAG of zero:% [SIZES]=EX2_20([],[],[],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',[55,175,555,475]) open_system(sys)end;set_param(sys,'algorithm', 'RK-45')set_param(sys,'Start time', '0.0')set_param(sys,'Stop time', '30')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', '[t,x,y]')add_block('built-in/Step Fcn',[sys,'/','Step Input'])set_param([sys,'/','Step Input'],... 'Time','0',... 'position',[50,35,70,55])add_block('built-in/Gain',[sys,'/','1//C'])set_param([sys,'/','1//C'],... 'position',[115,32,140,58])add_block('built-in/Integrator',[sys,'/','Integrator1'])set_param([sys,'/','Integrator1'],... 'position',[95,105,115,125])add_block('built-in/Gain',[sys,'/','1//RC'])set_param([sys,'/','1//RC'],... 'orientation',2,... 'position',[280,172,305,198])add_block('built-in/Gain',[sys,'/','1//LC'])set_param([sys,'/','1//LC'],... 'orientation',2,... 'Gain','.5',... 'position',[190,232,215,258])add_block('built-in/Sum',[sys,'/','Sum'])set_param([sys,'/','Sum'],... 'inputs','+--',... 'position',[215,87,235,143])add_block('built-in/Integrator',[sys,'/','Integrator2'])set_param([sys,'/','Integrator2'],... 'position',[330,105,350,125])add_block('built-in/Scope',[sys,'/','Scope'])set_param([sys,'/','Scope'],... 'Vgain','1.000000',... 'Hgain','30.000000',... 'Vmax','2.000000',... 'Hmax','60.000000',... 'Window',[383,276,714,590])open_system([sys,'/','Scope'])set_param([sys,'/','Scope'],... 'position',[425,100,455,130])add_block('built-in/Note',[sys,'/','y'])set_param([sys,'/','y'],... 'position',[405,125,410,130])add_line(sys,[75,45;110,45])add_line(sys,[185,245;70,245;70,115;90,115])add_line(sys,[275,185;190,185;190,135;210,135])add_line(sys,[240,115;325,115])add_line(sys,[355,115;420,115])add_line(sys,[385,115;385,185;310,185])add_line(sys,[385,185;385,245;220,245])add_line(sys,[120,115;210,115])add_line(sys,[145,45;170,45;170,95;210,95])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 + -