📄 spm1.m
字号:
function [ret,x0,str,ts,xts]=spm1(t,x,u,flag);
%SPM1 is the M-file description of the SIMULINK system named SPM1.
% The block-diagram can be displayed by typing: SPM1.
%
% SYS=SPM1(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 SPM1 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 SPM1 with a FLAG of zero:
% [SIZES]=SPM1([],[],[],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',[699,76,1199,376])
open_system(sys)
end;
set_param(sys,'BackGround',5)
set_param(sys,'algorithm', 'RK-45')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '999999')
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', '')
add_block('built-in/Product',[sys,'/','Product'])
set_param([sys,'/','Product'],...
'orientation',2,...
'BackGround',3,...
'Drop Shadow',4,...
'inputs','3',...
'position',[250,167,280,203])
add_block('built-in/Integrator',[sys,'/','Integrator1'])
set_param([sys,'/','Integrator1'],...
'BackGround',3,...
'Drop Shadow',4,...
'position',[195,77,225,113])
add_block('built-in/Integrator',[sys,'/','Integrator2'])
set_param([sys,'/','Integrator2'],...
'BackGround',3,...
'Drop Shadow',4,...
'position',[285,78,315,112])
add_block('built-in/Outport',[sys,'/','Outport'])
set_param([sys,'/','Outport'],...
'BackGround',4,...
'position',[395,85,415,105])
add_block('built-in/Sum',[sys,'/','Sum'])
set_param([sys,'/','Sum'],...
'BackGround',3,...
'Drop Shadow',4,...
'inputs','+---',...
'position',[140,72,160,118])
add_block('built-in/Inport',[sys,'/','Inport'])
set_param([sys,'/','Inport'],...
'BackGround',4,...
'position',[35,70,55,90])
add_block('built-in/Note',[sys,'/',[' .',13,'x2=x1']])
set_param([sys,'/',[' .',13,'x2=x1']],...
'position',[255,50,260,55])
add_block('built-in/Note',[sys,'/','y=x1'])
set_param([sys,'/','y=x1'],...
'position',[350,65,355,70])
add_block('built-in/Note',[sys,'/',['.',13,'x2']])
set_param([sys,'/',['.',13,'x2']],...
'position',[175,50,180,55])
add_line(sys,[320,95;390,95])
add_line(sys,[230,95;280,95])
add_line(sys,[60,80;135,80])
add_line(sys,[350,95;350,150;100,150;100,100;135,100])
add_line(sys,[250,95;250,145;115,145;115,110;135,110])
add_line(sys,[350,150;350,195;285,195])
add_line(sys,[350,185;285,185])
add_line(sys,[350,175;285,175])
add_line(sys,[245,185;90,185;90,90;135,90])
add_line(sys,[165,95;190,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);
end
else
drawnow % Flash up the model and execute load callback
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -