📄 ttrigfil.m
字号:
function [ret,x0,str,ts,xts]=ttrigfil(t,x,u,flag);
%TTRIGFIL is the M-file description of the SIMULINK system named TTRIGFIL.
% The block-diagram can be displayed by typing: TTRIGFIL.
%
% SYS=TTRIGFIL(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 TTRIGFIL 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 TTRIGFIL with a FLAG of zero:
% [SIZES]=TTRIGFIL([],[],[],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',[23,456,457,599])
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', '.10')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
add_block('built-in/Relational Operator',[sys,'/',['Relational',13,'Operator']])
set_param([sys,'/',['Relational',13,'Operator']],...
'hide name',0,...
'Operator','==',...
'position',[280,23,310,47])
add_block('built-in/Stop Simulation',[sys,'/','Stop Simulation'])
set_param([sys,'/','Stop Simulation'],...
'hide name',0,...
'position',[350,18,390,52])
% Subsystem ['Triggered write',13,'to file'].
new_system([sys,'/',['Triggered write',13,'to file']])
set_param([sys,'/',['Triggered write',13,'to file']],'Location',[105,608,345,754])
add_block('built-in/S-Function',[sys,'/',['Triggered write',13,'to file/S-function']])
set_param([sys,'/',['Triggered write',13,'to file/S-function']],...
'function name','swritfil',...
'parameters','filename, datatype, nump, threshold',...
'position',[135,70,185,90])
add_block('built-in/Mux',[sys,'/',['Triggered write',13,'to file/Mux']])
set_param([sys,'/',['Triggered write',13,'to file/Mux']],...
'inputs','2',...
'position',[65,61,100,94])
add_block('built-in/Inport',[sys,'/',['Triggered write',13,'to file/in_1']])
set_param([sys,'/',['Triggered write',13,'to file/in_1']],...
'position',[15,60,35,80])
add_block('built-in/Inport',[sys,'/',['Triggered write',13,'to file/in_2']])
set_param([sys,'/',['Triggered write',13,'to file/in_2']],...
'Port','2',...
'position',[15,75,35,95])
add_line([sys,'/',['Triggered write',13,'to file']],[105,80;130,80])
add_line([sys,'/',['Triggered write',13,'to file']],[40,70;60,70])
add_line([sys,'/',['Triggered write',13,'to file']],[40,85;60,85])
set_param([sys,'/',['Triggered write',13,'to file']],...
'Mask Display','plot(0,0,100,100,x,y,v,w);Wt file',...
'Mask Type','Write to file')
set_param([sys,'/',['Triggered write',13,'to file']],...
'Mask Dialogue','The rising edge of the signal from the\n2nd port triggers the block to write\nanother row into the specified file.|File name (string, include extension):|Data type (''ascii'', ''float'', ''integer''):|Number of trigger pulses between saved data:|Threshold in detecting trigger signal:')
set_param([sys,'/',['Triggered write',13,'to file']],...
'Mask Translate','filename=@1;datatype=@2;nump=@3;threshold=@4;[x,y]=srcsicon(8);[v,w]=trigicon(0,25,get_param(gcb,''orientation''),2);')
set_param([sys,'/',['Triggered write',13,'to file']],...
'Mask Help','This block writes the data inputted from the first port to the next row of the specified file at the rising edge of the second input trigger pulse. The first pulse triggers to write the first record. You can specify the number of pulses between writting records. When you specify ASCII format, there is no return added between two records.')
set_param([sys,'/',['Triggered write',13,'to file']],...
'Mask Entries','''junk.dat''\/''ascii''\/0\/0.5\/')
% Finished composite block ['Triggered write',13,'to file'].
set_param([sys,'/',['Triggered write',13,'to file']],...
'hide name',0,...
'position',[290,73,370,117])
add_block('built-in/Signal Generator',[sys,'/',['Signal',13,'generator1']])
set_param([sys,'/',['Signal',13,'generator1']],...
'hide name',0,...
'Peak','1.000000',...
'Peak Range','5.000000',...
'Freq','10.000000',...
'Freq Range','50.000000',...
'Wave','Sin',...
'Units','Rads')
set_param([sys,'/',['Signal',13,'generator1']],...
'position',[20,88,65,122])
add_block('built-in/S-Function',[sys,'/',['Triggered read',13,'from file']])
set_param([sys,'/',['Triggered read',13,'from file']],...
'function name','sreadfil',...
'parameters','filename,datatype,nump,numout,recursive,threshold',...
'Mask Display','plot(0,0,100,100,x,y,v,w); Rd file')
set_param([sys,'/',['Triggered read',13,'from file']],...
'Mask Type','Read from file')
set_param([sys,'/',['Triggered read',13,'from file']],...
'Mask Dialogue','The rising edge of the signal from the\n2nd port triggers the block to read the next row of the specified file.|File name (string, include extension):|Data type (''ascii'',''float'',''integer''):|Number of trigger pulse between saved data:|Output vector length:|Repeat flag (1: repeat read, 0: output zeros after eof):|Threshold in detecting trigger signal:')
set_param([sys,'/',['Triggered read',13,'from file']],...
'Mask Translate','filename=@1;datatype=@2;nump=@3;numout=@4;recursive=@5;threshold=@6;[x,y]=srcsicon(6);[v,w]=trigicon(0,50,get_param(gcb,''orientation''),2);')
set_param([sys,'/',['Triggered read',13,'from file']],...
'Mask Help','This block reads the data from a file. The output is refreshed at the rising edge of the input pulse. When the end of the file (eof) is reached, you can have the block output all zeros or start from the beginning of the file.')
set_param([sys,'/',['Triggered read',13,'from file']],...
'Mask Entries','''junk.tmp''\/''ascii''\/0\/1\/0\/.3\/',...
'position',[130,18,210,62])
add_line(sys,[70,105;285,105])
add_line(sys,[315,35;345,35])
add_line(sys,[90,105;90,40;125,40])
add_line(sys,[215,40;275,40])
add_line(sys,[255,40;255,85;285,85])
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 + -