📄 lab72.m
字号:
function [ret,x0,str,ts,xts]=lab72(t,x,u,flag);
%LAB72 is the M-file description of the SIMULINK system named LAB72.
% The block-diagram can be displayed by typing: LAB72.
%
% SYS=LAB72(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 LAB72 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 LAB72 with a FLAG of zero:
% [SIZES]=LAB72([],[],[],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',[68,176,466,458])
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.0001')
set_param(sys,'Max step size', '0.1')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
% Subsystem '零输入的线性二阶系统'.
new_system([sys,'/','零输入的线性二阶系统'])
set_param([sys,'/','零输入的线性二阶系统'],'Location',[61,93,520,388])
add_block('built-in/Outport',[sys,'/','零输入的线性二阶系统/out_1'])
set_param([sys,'/','零输入的线性二阶系统/out_1'],...
'position',[395,65,415,85])
add_block('built-in/Outport',[sys,'/','零输入的线性二阶系统/out_2'])
set_param([sys,'/','零输入的线性二阶系统/out_2'],...
'Port','2',...
'position',[395,110,415,130])
add_block('built-in/Integrator',[sys,'/','零输入的线性二阶系统/积分器'])
set_param([sys,'/','零输入的线性二阶系统/积分器'],...
'Initial','dx0',...
'position',[200,65,220,85])
add_block('built-in/Integrator',[sys,'/','零输入的线性二阶系统/积分器1'])
set_param([sys,'/','零输入的线性二阶系统/积分器1'],...
'Initial','x0',...
'position',[275,65,295,85])
add_block('built-in/Sum',[sys,'/','零输入的线性二阶系统/加法器'])
set_param([sys,'/','零输入的线性二阶系统/加法器'],...
'position',[135,65,155,85])
add_block('built-in/Gain',[sys,'/','零输入的线性二阶系统/放大器'])
set_param([sys,'/','零输入的线性二阶系统/放大器'],...
'orientation',2,...
'Gain','-fb*wn^2',...
'position',[170,20,190,40])
add_block('built-in/Gain',[sys,'/','零输入的线性二阶系统/放大器1'])
set_param([sys,'/','零输入的线性二阶系统/放大器1'],...
'orientation',2,...
'Gain','-2*q*wn',...
'position',[170,110,190,130])
add_line([sys,'/','零输入的线性二阶系统'],[225,75;270,75])
add_line([sys,'/','零输入的线性二阶系统'],[300,75;390,75])
add_line([sys,'/','零输入的线性二阶系统'],[245,75;245,120;390,120])
add_line([sys,'/','零输入的线性二阶系统'],[160,75;195,75])
add_line([sys,'/','零输入的线性二阶系统'],[315,75;315,30;195,30])
add_line([sys,'/','零输入的线性二阶系统'],[165,30;100,30;100,70;130,70])
add_line([sys,'/','零输入的线性二阶系统'],[380,120;195,120])
add_line([sys,'/','零输入的线性二阶系统'],[165,120;100,120;100,80;130,80])
set_param([sys,'/','零输入的线性二阶系统'],...
'Mask Display','零输入的线性二阶系统',...
'Mask Type','Linear Sys')
set_param([sys,'/','零输入的线性二阶系统'],...
'Mask Dialogue','零输入的线性二阶系统\n[x0,dx0]:系统初始值\n反馈类型:+1为正反馈;-1为负反馈.|阻尼比:|自然振荡频率:|系统初始值[x0,dx0]:|反馈类型(+1或-1): ')
set_param([sys,'/','零输入的线性二阶系统'],...
'Mask Translate','q=@1;wn=@2;x0=@3(1);dx0=@3(2);fb=-@4;',...
'Mask Help','零输入的线性二阶系统\n[x0,dx0]:系统初始值\n反馈类型:+1为正反馈;-1为负反馈.',...
'Mask Entries','0\/1\/[0 3]\/-1\/')
% Finished composite block '零输入的线性二阶系统'.
set_param([sys,'/','零输入的线性二阶系统'],...
'position',[50,114,185,156])
add_block('built-in/Note',[sys,'/',' 线性二阶系统'])
set_param([sys,'/',' 线性二阶系统'],...
'ForeGround',4,...
'Font Size',18,...
'position',[205,25,210,30])
add_block('built-in/Scope',[sys,'/','Scope'])
set_param([sys,'/','Scope'],...
'Vgain','3.000000',...
'Hgain','10.000000',...
'Vmax','6.000000',...
'Hmax','20.000000',...
'Window',[393,237,640,383])
open_system([sys,'/','Scope'])
set_param([sys,'/','Scope'],...
'position',[315,52,335,78])
% Subsystem 'XY 示波器'.
new_system([sys,'/','XY 示波器'])
set_param([sys,'/','XY 示波器'],'Location',[8,52,282,245])
add_block('built-in/S-Function',[sys,'/',['XY 示波器/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['XY 示波器/S-function',13,'M-file which plots',13,'lines',13,'']],...
'function name','sfunxy',...
'parameters','ax, st',...
'position',[185,70,235,90])
add_block('built-in/Mux',[sys,'/','XY 示波器/Mux'])
set_param([sys,'/','XY 示波器/Mux'],...
'inputs','2',...
'position',[100,61,130,94])
add_block('built-in/Inport',[sys,'/','XY 示波器/x'])
set_param([sys,'/','XY 示波器/x'],...
'position',[10,30,30,50])
add_block('built-in/Inport',[sys,'/','XY 示波器/y'])
set_param([sys,'/','XY 示波器/y'],...
'Port','2',...
'position',[10,100,30,120])
add_line([sys,'/','XY 示波器'],[135,80;180,80])
add_line([sys,'/','XY 示波器'],[35,40;70,40;70,70;95,70])
add_line([sys,'/','XY 示波器'],[35,110;70,110;70,85;95,85])
set_param([sys,'/','XY 示波器'],...
'Mask Display','plot(0,0,100,100,[12,91,91,12,12],[90,90,45,45,90],[51,57,65,75,80,79,75,67,60,54,51,48,42,34,28,27,31,42,51],[71,68,66,66,72,79,83,84,81,77,71,60,54,54,58,65,71,74,71])')
set_param([sys,'/','XY 示波器'],...
'Mask Type','XY scope.',...
'Mask Dialogue','XY scope using MATLAB graph window.\nFirst input is used as time base.\nEnter plotting ranges.|x-min:|x-max:|y-min:|y-max:')
set_param([sys,'/','XY 示波器'],...
'Mask Translate','ax = [@1, @2, @3, @4];st=-1;',...
'Mask Help','This block can be used to explore limit cycles. Look at the m-file sfunxy.m to see how it works.',...
'Mask Entries','-3\/3\/-3\/3\/')
% Finished composite block 'XY 示波器'.
set_param([sys,'/','XY 示波器'],...
'position',[315,116,345,154])
add_block('built-in/Scope',[sys,'/','Scope1'])
set_param([sys,'/','Scope1'],...
'Vgain','3.000000',...
'Hgain','10.000000',...
'Vmax','6.000000',...
'Hmax','20.000000',...
'Window',[393,334,640,480])
open_system([sys,'/','Scope1'])
set_param([sys,'/','Scope1'],...
'position',[320,182,340,208])
add_block('built-in/Note',[sys,'/',' .'])
set_param([sys,'/',' .'],...
'Font Size',24,...
'position',[255,125,260,130])
add_block('built-in/Note',[sys,'/','输出的导数 X'])
set_param([sys,'/','输出的导数 X'],...
'position',[235,155,240,160])
add_block('built-in/Note',[sys,'/','输出 X'])
set_param([sys,'/','输出 X'],...
'position',[230,105,235,110])
add_line(sys,[190,145;310,145])
add_line(sys,[190,125;310,125])
add_line(sys,[285,125;285,65;310,65])
add_line(sys,[285,145;285,195;315,195])
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 + -