📄 s2.m
字号:
function [ret,x0,str,ts,xts]=s2(t,x,u,flag);
%s2 is the M-file description of the SIMULINK system named s2.
% The block-diagram can be displayed by typing: s2.
%
% SYS=s2(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 s2 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 s2 with a FLAG of zero:
% [SIZES]=s2([],[],[],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',[63,66,783,583])
open_system(sys)
end;
set_param(sys,'algorithm', 'Adams/Gear')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '5')
set_param(sys,'Min step size', '0.0005')
set_param(sys,'Max step size', '0.005')
set_param(sys,'Relative error','1e-6')
set_param(sys,'Return vars', '')
add_block('built-in/Constant',[sys,'/','Tmech'])
set_param([sys,'/','Tmech'],...
'Value','0',...
'position',[400,211,430,229])
add_block('built-in/Scope',[sys,'/','Scope'])
set_param([sys,'/','Scope'],...
'Vgain','300.000000',...
'Hgain','7.000000',...
'Vmax','600.000000',...
'Hmax','14.000000',...
'Window',[29,451,808,625])
open_system([sys,'/','Scope'])
set_param([sys,'/','Scope'],...
'position',[565,59,585,81])
add_block('built-in/To Workspace',[sys,'/','To Workspace'])
set_param([sys,'/','To Workspace'],...
'mat-name','y',...
'buffer','2000',...
'position',[540,21,610,39])
add_block('built-in/Gain',[sys,'/','r2'])
set_param([sys,'/','r2'],...
'orientation',2,...
'Gain','0.523',...
'position',[230,388,290,422])
add_block('built-in/Note',[sys,'/','wm'])
set_param([sys,'/','wm'],...
'position',[635,165,640,170])
add_block('built-in/Clock',[sys,'/','Clock'])
set_param([sys,'/','Clock'],...
'position',[240,65,260,85])
add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
'orientation',3,...
'position',[279,40,481,60])
add_block('built-in/Gain',[sys,'/','D'])
set_param([sys,'/','D'],...
'orientation',2,...
'Gain','D',...
'position',[505,125,560,155])
add_block('built-in/Constant',[sys,'/','kaphi'])
set_param([sys,'/','kaphi'],...
'Value','1.3',...
'position',[235,150,275,170])
% Subsystem 'Product2'.
new_system([sys,'/','Product2'])
set_param([sys,'/','Product2'],'Location',[33,479,253,634])
add_block('built-in/Product',[sys,'/','Product2/Product'])
set_param([sys,'/','Product2/Product'],...
'position',[65,55,90,75])
add_block('built-in/Sum',[sys,'/','Product2/Sum'])
set_param([sys,'/','Product2/Sum'],...
'inputs','+',...
'position',[125,55,145,75])
add_block('built-in/Outport',[sys,'/','Product2/out_1'])
set_param([sys,'/','Product2/out_1'],...
'position',[185,55,205,75])
add_block('built-in/Inport',[sys,'/','Product2/in_2'])
set_param([sys,'/','Product2/in_2'],...
'Port','2',...
'position',[15,90,35,110])
add_block('built-in/Inport',[sys,'/','Product2/in_1'])
set_param([sys,'/','Product2/in_1'],...
'position',[15,25,35,45])
add_line([sys,'/','Product2'],[40,100;60,70])
add_line([sys,'/','Product2'],[40,35;60,60])
add_line([sys,'/','Product2'],[95,65;120,65])
add_line([sys,'/','Product2'],[150,65;180,65])
set_param([sys,'/','Product2'],...
'Mask Display','.\n',...
'Mask Type','Dot Product',...
'Mask Dialogue','Inner (dot) product.\ny=sum(u1.*u2)')
set_param([sys,'/','Product2'],...
'Mask Help','Computes the inner (dot) product of the inputs: sum(u1.*u2). The inputs are vectors of the same length. Output is a scalar.')
% Finished composite block 'Product2'.
set_param([sys,'/','Product2'],...
'orientation',2,...
'position',[170,103,195,132])
add_block('built-in/Note',[sys,'/','Ea'])
set_param([sys,'/','Ea'],...
'position',[140,91,145,96])
% Subsystem 'Product'.
new_system([sys,'/','Product'])
set_param([sys,'/','Product'],'Location',[33,479,253,634])
add_block('built-in/Product',[sys,'/','Product/Product'])
set_param([sys,'/','Product/Product'],...
'position',[65,55,90,75])
add_block('built-in/Sum',[sys,'/','Product/Sum'])
set_param([sys,'/','Product/Sum'],...
'inputs','+',...
'position',[125,55,145,75])
add_block('built-in/Outport',[sys,'/','Product/out_1'])
set_param([sys,'/','Product/out_1'],...
'position',[185,55,205,75])
add_block('built-in/Inport',[sys,'/','Product/in_2'])
set_param([sys,'/','Product/in_2'],...
'Port','2',...
'position',[15,90,35,110])
add_block('built-in/Inport',[sys,'/','Product/in_1'])
set_param([sys,'/','Product/in_1'],...
'position',[15,25,35,45])
add_line([sys,'/','Product'],[40,100;60,70])
add_line([sys,'/','Product'],[40,35;60,60])
add_line([sys,'/','Product'],[95,65;120,65])
add_line([sys,'/','Product'],[150,65;180,65])
set_param([sys,'/','Product'],...
'Mask Display','.\n',...
'Mask Type','Dot Product',...
'Mask Dialogue','Inner (dot) product.\ny=sum(u1.*u2)')
set_param([sys,'/','Product'],...
'Mask Help','Computes the inner (dot) product of the inputs: sum(u1.*u2). The inputs are vectors of the same length. Output is a scalar.')
% Finished composite block 'Product'.
set_param([sys,'/','Product'],...
'position',[355,181,380,219])
add_block('built-in/Integrator',[sys,'/','Integrator'])
set_param([sys,'/','Integrator'],...
'position',[265,194,300,226])
add_block('built-in/Gain',[sys,'/','1//J'])
set_param([sys,'/','1//J'],...
'Gain','1/J',...
'position',[495,164,540,206])
add_block('built-in/Constant',[sys,'/','Vdc- Vbrush'])
set_param([sys,'/','Vdc- Vbrush'],...
'Value','218',...
'position',[35,155,70,185])
add_block('built-in/Memory',[sys,'/','Memory2'])
set_param([sys,'/','Memory2'],...
'orientation',1,...
'position',[602,415,628,435])
add_block('built-in/Gain',[sys,'/','1//Laq'])
set_param([sys,'/','1//Laq'],...
'Gain','1/Laq',...
'position',[180,189,225,231])
add_block('built-in/Logical Operator',[sys,'/','a1'])
set_param([sys,'/','a1'],...
'orientation',2,...
'Operator','AND',...
'position',[465,432,500,463])
add_block('built-in/Note',[sys,'/','Tem'])
set_param([sys,'/','Tem'],...
'position',[400,165,405,170])
add_block('built-in/Derivative',[sys,'/','Deriv'])
set_param([sys,'/','Deriv'],...
'position',[510,243,550,277])
add_block('built-in/Relational Operator',[sys,'/','<=Iamin'])
set_param([sys,'/','<=Iamin'],...
'Operator','<=',...
'position',[410,254,435,281])
add_block('built-in/Logical Operator',[sys,'/','and'])
set_param([sys,'/','and'],...
'Operator','AND',...
'position',[455,240,480,280])
% Subsystem 'Latch'.
new_system([sys,'/','Latch'])
set_param([sys,'/','Latch'],'Location',[102,336,551,502])
add_block('built-in/Fcn',[sys,'/','Latch/Fcn'])
set_param([sys,'/','Latch/Fcn'],...
'orientation',2,...
'Expr','u[1]>.2',...
'position',[170,123,205,147])
add_block('built-in/Demux',[sys,'/','Latch/Demux'])
set_param([sys,'/','Latch/Demux'],...
'outputs','2',...
'position',[275,55,315,90])
add_block('built-in/Combinatorial Logic',[sys,'/','Latch/Logic'])
set_param([sys,'/','Latch/Logic'],...
'Truth Table','[0 1;1 0;0 1;0 1;1 0;1 0;0 0;0 0]',...
'position',[195,55,250,95])
add_block('built-in/Transport Delay',[sys,'/','Latch/Transport Delay'])
set_param([sys,'/','Latch/Transport Delay'],...
'orientation',2,...
'Initial Input','ini',...
'position',[250,120,295,150])
add_block('built-in/Outport',[sys,'/','Latch/out_2'])
set_param([sys,'/','Latch/out_2'],...
'Port','2',...
'position',[395,70,415,90])
add_block('built-in/Outport',[sys,'/','Latch/out_1'])
set_param([sys,'/','Latch/out_1'],...
'position',[355,55,375,75])
add_block('built-in/Mux',[sys,'/','Latch/Mux'])
set_param([sys,'/','Latch/Mux'],...
'inputs','3',...
'position',[135,59,165,91])
add_block('built-in/Inport',[sys,'/','Latch/in_1'])
set_param([sys,'/','Latch/in_1'],...
'position',[20,50,40,70])
add_block('built-in/Inport',[sys,'/','Latch/in_2'])
set_param([sys,'/','Latch/in_2'],...
'Port','2',...
'position',[50,65,70,85])
add_line([sys,'/','Latch'],[320,65;350,65])
add_line([sys,'/','Latch'],[335,65;335,135;300,135])
add_line([sys,'/','Latch'],[165,135;110,135;110,85;130,85])
add_line([sys,'/','Latch'],[245,135;210,135])
add_line([sys,'/','Latch'],[75,75;130,75])
add_line([sys,'/','Latch'],[45,60;105,60;105,65;130,65])
add_line([sys,'/','Latch'],[170,75;190,75])
add_line([sys,'/','Latch'],[255,75;270,75])
add_line([sys,'/','Latch'],[320,80;390,80])
set_param([sys,'/','Latch'],...
'Mask Display','S 1\n\nR 0',...
'Mask Type','Latch',...
'Mask Dialogue','Latch|Initial State for Output "1":',...
'Mask Translate','ini=(@1~=0);')
set_param([sys,'/','Latch'],...
'Mask Help','Latches the S input. When S (set) is one, the uncomplemented output (1) becomes one. The output remains one until the R (reset) input becomes one, forcing the output to zero. If both R and S are one, the latch will be in an undefined state.')
set_param([sys,'/','Latch'],...
'Mask Entries','0\/')
% Finished composite block 'Latch'.
set_param([sys,'/','Latch'],...
'position',[385,325,415,365])
add_block('built-in/Memory',[sys,'/','Memory1'])
set_param([sys,'/','Memory1'],...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -