📄 c2ex21.m
字号:
function [ret,x0,str,ts,xts]=c2ex23(t,x,u,flag);%C2EX23 is the M-file description of the SIMULINK system named C2EX23.% The block-diagram can be displayed by typing: C2EX23.%% SYS=C2EX23(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 C2EX23 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 C2EX23 with a FLAG of zero:% [SIZES]=C2EX23([],[],[],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',[99,61,599,361]) open_system(sys)end;set_param(sys,'algorithm', 'RK-45')set_param(sys,'Start time', '0.0')set_param(sys,'Stop time', '10')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,q]')add_block('built-in/Note',[sys,'/','i(t)'])set_param([sys,'/','i(t)'],... 'position',[195,40,200,45])add_block('built-in/Step Fcn',[sys,'/','Step Input'])set_param([sys,'/','Step Input'],... 'Time','0',... 'position',[25,40,45,60])add_block('built-in/Gain',[sys,'/','K//L'])set_param([sys,'/','K//L'],... 'orientation',2,... 'position',[235,152,260,178])add_block('built-in/Note',[sys,'/','OMEGA'])set_param([sys,'/','OMEGA'],... 'position',[410,40,415,45])add_block('built-in/Scope',[sys,'/','Scope'])set_param([sys,'/','Scope'],... 'Vgain','0.800000',... 'Hgain','10.000000',... 'Vmax','1.600000',... 'Hmax','20.000000',... 'Window',[240,108,571,422])open_system([sys,'/','Scope'])set_param([sys,'/','Scope'],... 'position',[450,50,480,80])add_block('built-in/Gain',[sys,'/','B//J'])set_param([sys,'/','B//J'],... 'orientation',2,... 'Gain','.707',... 'position',[335,112,360,138])add_block('built-in/Integrator',[sys,'/','Integrator2'])set_param([sys,'/','Integrator2'],... 'position',[370,55,390,75])add_block('built-in/Sum',[sys,'/','Sum1'])set_param([sys,'/','Sum1'],... 'inputs','+-',... 'position',[300,55,320,75])add_block('built-in/Gain',[sys,'/','R//L'])set_param([sys,'/','R//L'],... 'orientation',2,... 'Gain','.707',... 'position',[135,112,160,138])add_block('built-in/Gain',[sys,'/','K//J'])set_param([sys,'/','K//J'],... 'position',[235,47,260,73])add_block('built-in/Integrator',[sys,'/','Integrator1'])set_param([sys,'/','Integrator1'],... 'position',[165,50,185,70])add_block('built-in/Sum',[sys,'/','Sum'])set_param([sys,'/','Sum'],... 'inputs','+--',... 'position',[95,42,115,78])add_line(sys,[50,50;90,50])add_line(sys,[120,60;160,60])add_line(sys,[190,60;230,60])add_line(sys,[265,60;295,60])add_line(sys,[325,65;365,65])add_line(sys,[395,65;445,65])add_line(sys,[405,65;405,125;365,125])add_line(sys,[330,125;275,125;275,70;295,70])add_line(sys,[205,60;205,125;165,125])add_line(sys,[405,125;405,165;265,165])add_line(sys,[230,165;65,165;65,60;90,60])add_line(sys,[130,125;70,125;70,70;90,70])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 + -