📄 ben3asys.m
字号:
function [ret,x0,str,ts,xts]=ben3asys(t,x,u,flag);
%BEN3ASYS is the M-file description of the SIMULINK system named BEN3ASYS.
% The block-diagram can be displayed by typing: BEN3ASYS.
%
% SYS=BEN3ASYS(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 BEN3ASYS 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 BEN3ASYS with a FLAG of zero:
% [SIZES]=BEN3ASYS([],[],[],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',[32,103,758,340])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-23')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '4')
set_param(sys,'Min step size', '1e-4')
set_param(sys,'Max step size', '10')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
set_param(sys,'Load callback','ben3adat');
add_block('built-in/Note',[sys,'/','T1'])
set_param([sys,'/','T1'],...
'position',[310,15,315,20])
add_block('built-in/Discrete Transfer Fcn',[sys,'/','G3'])
set_param([sys,'/','G3'],...
'Numerator','gn3',...
'Denominator','gd3',...
'Sample time','[T1,offT1]',...
'position',[150,12,200,48])
add_block('built-in/Discrete Transfer Fcn',[sys,'/','G4'])
set_param([sys,'/','G4'],...
'orientation',2,...
'Numerator','gn4',...
'Denominator','gd4',...
'Sample time','[T1,offT1]',...
'position',[320,92,370,128])
add_block('built-in/Discrete Transfer Fcn',[sys,'/','G5'])
set_param([sys,'/','G5'],...
'orientation',2,...
'Numerator','gn5',...
'Denominator','gd5',...
'Sample time','[T1,offT1]',...
'position',[320,157,370,193])
add_block('built-in/Discrete Transfer Fcn',[sys,'/','G7'])
set_param([sys,'/','G7'],...
'orientation',2,...
'Numerator','gn7',...
'Denominator','gd7',...
'Sample time','[T2,offT2]',...
'position',[430,157,480,193])
add_block('built-in/Discrete Transfer Fcn',[sys,'/','G6'])
set_param([sys,'/','G6'],...
'orientation',2,...
'Numerator','gn6',...
'Denominator','gd6',...
'Sample time','[T2,offT2]',...
'position',[430,92,480,128])
add_block('built-in/Step Fcn',[sys,'/','Step'])
set_param([sys,'/','Step'],...
'Time','0',...
'position',[40,15,60,35])
add_block('built-in/Note',[sys,'/','T2 '])
set_param([sys,'/','T2 '],...
'position',[525,80,530,87])
add_block('built-in/Note',[sys,'/','T2'])
set_param([sys,'/','T2'],...
'position',[525,140,530,147])
add_block('built-in/Note',[sys,'/',' T1 '])
set_param([sys,'/',' T1 '],...
'position',[390,80,395,87])
add_block('built-in/Note',[sys,'/','T1 '])
set_param([sys,'/','T1 '],...
'position',[385,145,401,150])
add_block('built-in/Transfer Fcn',[sys,'/','G1, G2'])
set_param([sys,'/','G1, G2'],...
'Numerator','gn1_gn2',...
'Denominator','gd1',...
'position',[420,19,485,61])
add_block('built-in/Sum',[sys,'/','Sum1'])
set_param([sys,'/','Sum1'],...
'hide name',0,...
'inputs','2',...
'position',[285,28,300,52])
add_block('built-in/Sum',[sys,'/','Sum'])
set_param([sys,'/','Sum'],...
'hide name',0,...
'inputs','--',...
'position',[235,23,250,47])
add_block('built-in/Inport',[sys,'/','R'])
set_param([sys,'/','R'],...
'position',[40,70,60,90])
add_block('built-in/Sum',[sys,'/','Sum2'])
set_param([sys,'/','Sum2'],...
'hide name',0,...
'position',[110,20,130,40])
add_block('built-in/Discrete Transfer Fcn',[sys,'/',['Zero Order',13,'Hold']])
set_param([sys,'/',['Zero Order',13,'Hold']],...
'Numerator','1',...
'Denominator','1',...
'Sample time','[T1,offZOH]',...
'position',[320,22,370,58])
add_block('built-in/Demux',[sys,'/','Demux1'])
set_param([sys,'/','Demux1'],...
'hide name',0,...
'outputs','2',...
'position',[515,18,555,62])
add_block('built-in/To Workspace',[sys,'/','C1 data'])
set_param([sys,'/','C1 data'],...
'mat-name','C1_data',...
'buffer','12000',...
'position',[625,100,685,120])
add_block('built-in/Scope',[sys,'/','C1'])
set_param([sys,'/','C1'],...
'Vgain','1.270000',...
'Hgain','4.100000',...
'Vmax','2.000000',...
'Hmax','8.200000',...
'Window',[588,157,848,346],...
'position',[625,8,660,52])
add_block('built-in/Outport',[sys,'/','C1(t)'])
set_param([sys,'/','C1(t)'],...
'position',[630,160,650,180])
add_line(sys,[135,30;145,30])
add_line(sys,[65,80;80,80;80,35;105,35])
add_line(sys,[65,25;105,25])
add_line(sys,[315,175;218,175;218,40;230,40])
add_line(sys,[315,110;260,110;260,45;280,45])
add_line(sys,[425,110;375,110])
add_line(sys,[205,30;230,30])
add_line(sys,[305,40;315,40])
add_line(sys,[255,35;280,35])
add_line(sys,[425,175;375,175])
add_line(sys,[375,40;415,40])
add_line(sys,[490,40;510,40])
add_line(sys,[560,50;570,50;570,175;485,175])
add_line(sys,[560,30;595,30;595,110;485,110])
add_line(sys,[560,30;620,30])
add_line(sys,[560,30;595,30;595,170;625,170])
add_line(sys,[595,110;620,110])
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 + -