📄 lab1.m
字号:
function [ret,x0,str,ts,xts]=lab1(t,x,u,flag);
%LAB1 is the M-file description of the SIMULINK system named LAB1.
% The block-diagram can be displayed by typing: LAB1.
%
% SYS=LAB1(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 LAB1 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 LAB1 with a FLAG of zero:
% [SIZES]=LAB1([],[],[],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',[150,361,659,591])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-45')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '2')
set_param(sys,'Min step size', '0.0001')
set_param(sys,'Max step size', '.01')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
add_block('built-in/Note',[sys,'/','实验窗口'])
set_param([sys,'/','实验窗口'],...
'ForeGround',4,...
'Font Size',18,...
'position',[250,15,255,20])
add_block('built-in/Step Fcn',[sys,'/','阶跃信号'])
set_param([sys,'/','阶跃信号'],...
'Time','Start_T',...
'Before','Init_V',...
'After','Final_V',...
'Mask Display','',...
'Mask Dialogue','阶跃信号:\n 信号在阶跃时刻由初始值跳变到终值。|阶跃时刻:|初始值:|终值:')
set_param([sys,'/','阶跃信号'],...
'Mask Translate','Start_T=@1;Init_V=@2;Final_V=@3;',...
'Mask Help','阶跃信号:\n 信号在阶跃时刻由初始值跳变到终值。',...
'Mask Entries','0\/0\/1\/',...
'position',[100,50,130,80])
add_block('built-in/Scope',[sys,'/','示波器'])
set_param([sys,'/','示波器'],...
'Vgain','1.802000',...
'Hgain','1.512000',...
'Vmax','2.000000',...
'Hmax','3.024000',...
'Window',[365,325,723,637],...
'position',[275,50,300,80])
add_block('built-in/Transfer Fcn',[sys,'/','S传递函数'])
set_param([sys,'/','S传递函数'],...
'Drop Shadow',4,...
'Denominator','[1 1]',...
'position',[185,47,220,83])
add_line(sys,[135,65;180,65])
add_line(sys,[225,65;270,65])
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 + -