td_dem_s.m
来自「FISMAT accommodates different arithmetic」· M 代码 · 共 178 行
M
178 行
function [ret,x0,str]=td_dem_s(t,x,u,flag);%TD_DEM_S is the M-file description of the SIMULINK system named TD_DEM_S.% The block-diagram can be displayed by typing: TD_DEM_S.%% SYS=TD_DEM_S(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 TD_DEM_S 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 TD_DEM_S with a FLAG of zero:% [SIZES]=TD_DEM_S([],[],[],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.% 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.2)if(0 == (nargin + nargout)) set_param(sys,'Location',[0,279,624,443]) open_system(sys)end;set_param(sys,'algorithm', 'RK-45')set_param(sys,'Start time', '0.0')set_param(sys,'Stop time', '20')set_param(sys,'Min step size', '0.0001')set_param(sys,'Max step size', '1')set_param(sys,'Relative error','1e-3')set_param(sys,'Return vars', '')% Subsystem 'Graph Scope'.new_system([sys,'/','Graph Scope'])set_param([sys,'/','Graph Scope'],'Location',[0,0,274,193])add_block('built-in/S-function',[sys,'/',['Graph Scope/S-function',13,'M-file which plots',13,'lines',13,'']])set_param([sys,'/',['Graph Scope/S-function',13,'M-file which plots',13,'lines',13,'']],... 'function name','sfuny',... 'parameters','ax, color',... 'position',[130,55,180,75])add_block('built-in/Inport',[sys,'/','Graph Scope/x'])set_param([sys,'/','Graph Scope/x'],... 'position',[65,55,85,75])add_line([sys,'/','Graph Scope'],[90,65;120,65])set_param([sys,'/','Graph Scope'],... 'Mask Display','plot(0,0,100,100,[90,10,10,10,90,90,10],[65,65,90,40,40,90,90],[90,78,69,54,40,31,25,10],[77,60,48,46,56,75,81,84])',... 'Mask Type','Graph scope.')set_param([sys,'/','Graph Scope'],... 'Mask Dialogue','Graph scope using MATLAB graph window.\nEnter plotting ranges and line type.|Time range:|y-min:|y-max:|Line type (rgbw-:*):',... 'Mask Translate','color = @4; ax = [0, @1, @2, @3];')set_param([sys,'/','Graph Scope'],... 'Mask Help','This block plots to the MATLAB graph window and can be used as an improved version of the Scope block. Look at the m-file sfuny.m to see how it works.',... 'Mask Entries','20\/0\/1.2\/''y-''\/')% Finished composite block 'Graph Scope'.set_param([sys,'/','Graph Scope'],... 'Drop Shadow',4,... 'position',[455,326,485,364])add_block('built-in/Transport Delay',[sys,'/','Transport Delay'])set_param([sys,'/','Transport Delay'],... 'Delay Time','2',... 'position',[545,80,590,110])add_block('built-in/Transfer Fcn',[sys,'/','Transfer Fcn'])set_param([sys,'/','Transfer Fcn'],... 'Denominator','[1 1]',... 'position',[490,77,525,113])add_block('built-in/Integrator',[sys,'/','Integrator'])set_param([sys,'/','Integrator'],... 'position',[445,85,465,105])add_block('built-in/Gain',[sys,'/','Gain1'])set_param([sys,'/','Gain1'],... 'Gain','0.05',... 'position',[410,85,430,105])add_block('built-in/S-function',[sys,'/','S-function'])set_param([sys,'/','S-function'],... 'function name','fuzzy21',... 'parameters','''td_dem_c'',1',... 'position',[345,85,395,105])add_block('built-in/Mux',[sys,'/','Mux'])set_param([sys,'/','Mux'],... 'inputs','2',... 'position',[295,75,325,110])add_block('built-in/Gain',[sys,'/','Gain2'])set_param([sys,'/','Gain2'],... 'position',[240,105,260,125])add_block('built-in/Unit Delay',[sys,'/','Unit Delay'])set_param([sys,'/','Unit Delay'],... 'position',[155,177,205,193])add_block('built-in/Sum',[sys,'/','Sum'])set_param([sys,'/','Sum'],... 'inputs','++-',... 'position',[100,62,120,98])add_block('built-in/Constant',[sys,'/','Constant'])set_param([sys,'/','Constant'],... 'Value','0.5',... 'position',[15,110,35,130])add_block('built-in/Gain',[sys,'/','Gain3'])set_param([sys,'/','Gain3'],... 'Gain','0.04',... 'position',[185,20,205,40])add_block('built-in/Gain',[sys,'/','Gain4'])set_param([sys,'/','Gain4'],... 'position',[240,70,260,90])add_block('built-in/Signal Generator',[sys,'/','Signal Gen.'])set_param([sys,'/','Signal Gen.'],... 'Peak','0.500000',... 'Peak Range','5.000000',... 'Freq','0.157100',... 'Freq Range','5.000000',... 'Wave','Sqr',... 'Units','Rads')open_system([sys,'/','Signal Gen.'])set_param([sys,'/','Signal Gen.'],... 'position',[10,8,55,42])add_block('built-in/Step Fcn',[sys,'/','Step Fcn'])set_param([sys,'/','Step Fcn'],... 'Time','0',... 'position',[30,60,50,80])add_line(sys,[125,80;230,80])add_line(sys,[530,95;535,95])add_line(sys,[400,95;400,95])add_line(sys,[330,95;335,95])add_line(sys,[265,115;285,100])add_line(sys,[210,185;215,185;215,115;230,115])add_line(sys,[435,95;435,95])add_line(sys,[470,95;480,95])add_line(sys,[125,80;125,185;145,185])add_line(sys,[595,95;610,95;610,275;60,275;60,125;90,90])add_line(sys,[40,120;84,89;90,80])add_line(sys,[390,275;390,345;445,345])add_line(sys,[265,80;265,80;285,85])add_line(sys,[55,70;90,70])% 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]=',sys,'(t,x,u,flag);']) else eval(['ret =', sys,'(t,x,u,flag);']) end else [ret,x0,str] = feval(sys); endend
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?