📄 tabdemo.m
字号:
function [ret,x0,str]=tabdemo(t,x,u,flag);
%TABDEMO is the M-file description of the SIMULINK system named TABDEMO.
% The block-diagram can be displayed by typing: TABDEMO.
%
% SYS=TABDEMO(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 TABDEMO to return state derivitives, FLAG=2
% discrete states, FLAG=3 system outputs and FLAG=4 next sample
% time. For more information and other options see SFUNC.
%
% Calling TABDEMO with a FLAG of zero:
% [SIZES]=TABDEMO([],[],[],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.
% For the definition of other parameters in SIZES, see SFUNC.
% See also, TRIM, LINMOD, LINSIM, EULER, RK23, RK45, ADAMS, GEAR.
% Copyright (c) 1990-94 by The MathWorks, Inc.
% 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',[0,0,394,192])
open_system(sys)
end;
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', '0.05')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
% Subsystem '2-D Table Lookup'.
new_system([sys,'/','2-D Table Lookup'])
set_param([sys,'/','2-D Table Lookup'],'Location',[316,263,598,417])
add_block('built-in/Inport',[sys,'/','2-D Table Lookup/y0'])
set_param([sys,'/','2-D Table Lookup/y0'],...
'Port','2',...
'position',[20,80,40,100])
add_block('built-in/Outport',[sys,'/','2-D Table Lookup/table out'])
set_param([sys,'/','2-D Table Lookup/table out'],...
'Port','1',...
'position',[215,55,235,75])
add_block('built-in/Inport',[sys,'/','2-D Table Lookup/x0'])
set_param([sys,'/','2-D Table Lookup/x0'],...
'Port','1',...
'position',[20,25,40,45])
add_block('built-in/S-function',[sys,'/','2-D Table Lookup/S-function'])
set_param([sys,'/','2-D Table Lookup/S-function'],...
'function name','sftable2',...
'parameters','xindex, yindex, table',...
'position',[140,52,190,78])
add_block('built-in/Mux',[sys,'/','2-D Table Lookup/Mux'])
set_param([sys,'/','2-D Table Lookup/Mux'],...
'inputs','2',...
'position',[90,46,120,79])
add_line([sys,'/','2-D Table Lookup'],[45,90;65,90;65,70;85,70])
add_line([sys,'/','2-D Table Lookup'],[195,65;210,65])
add_line([sys,'/','2-D Table Lookup'],[45,35;65,35;65,55;85,55])
add_line([sys,'/','2-D Table Lookup'],[125,65;135,65])
set_param([sys,'/','2-D Table Lookup'],...
'Mask Display','plot(-10,-10,110,110,[90,50,10],[90,40,30],[90,50,10],[50,26,20],[90,50,10],[22,13,10])',...
'Mask Type','2-D Table Lookup')
set_param([sys,'/','2-D Table Lookup'],...
'Mask Dialogue','Two Dimensional Table Lookup\nThe first input corresponds to X Index and the second input corresponds to the Y Index|X Index|Y Index|Table')
set_param([sys,'/','2-D Table Lookup'],...
'Mask Translate','xindex=@1; yindex=@2; table=@3; sftab2chk(xindex,yindex,table);')
set_param([sys,'/','2-D Table Lookup'],...
'Mask Help','This block returns a linearly interpolated intersection from the table using the X index (which corresponds to the rows of the table) and the Y index (which corresponds to the columns of the table). Extrapolation is used.')
set_param([sys,'/','2-D Table Lookup'],...
'Mask Entries','sort(rand(10,1))*2-1\/sort(rand(10,1))*2-1\/magic(10)-50\/')
% Finished composite block '2-D Table Lookup'.
set_param([sys,'/','2-D Table Lookup'],...
'position',[205,64,250,106])
add_block('built-in/Signal Generator',[sys,'/','Signal Gen.'])
set_param([sys,'/','Signal Gen.'],...
'Peak','1.000000',...
'Peak Range','5.000000',...
'Freq','1.000000',...
'Freq Range','5.000000',...
'Wave','Sin',...
'Units','Rads',...
'position',[50,28,95,62])
add_block('built-in/Scope',[sys,'/','Scope'])
set_param([sys,'/','Scope'],...
'Vgain','100',...
'Hgain','10',...
'Vmax','200',...
'Hmax','20',...
'Window',[0,0,280,220],...
'position',[335,72,355,98])
add_block('built-in/Signal Generator',[sys,'/','Signal Gen.1'])
set_param([sys,'/','Signal Gen.1'],...
'Peak','1.000000',...
'Peak Range','5.000000',...
'Freq','1.000000',...
'Freq Range','5.000000',...
'Wave','Sin',...
'Units','Rads',...
'position',[50,108,95,142])
add_line(sys,[100,45;145,45;145,75;200,75])
add_line(sys,[100,125;145,125;145,95;200,95])
add_line(sys,[255,85;330,85])
% Return any arguments.
if (nargin | nargout)
% Must use feval here to access system in memory
if (nargin > 3)
if (flag == 0)
eval(['[ret,x0,xstr]=',sys,'(t,x,u,flag);'])
else
eval(['ret =', sys,'(t,x,u,flag);'])
end
else
[ret,x0,str] = feval(sys);
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -