📄 tsttcm.m
字号:
function [ret,x0,str,ts,xts]=tsttcm(t,x,u,flag);
%TSTTCM is the M-file description of the SIMULINK system named TSTTCM.
% The block-diagram can be displayed by typing: TSTTCM.
%
% SYS=TSTTCM(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 TSTTCM 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 TSTTCM with a FLAG of zero:
% [SIZES]=TSTTCM([],[],[],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',[213,65,973,417])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-45')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '103')
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', '')
set_param(sys,'Nonreal-time algorithm','None')
set_param(sys,'Nonreal-time max step size','.5')
set_param(sys,'Nonreal-time min step size','.5')
set_param(sys,'Nonreal-time stop time','103')
set_param(sys,'Nonreal-time build command','make_nrt OPTS=-Dinf=1.e100')
set_param(sys,'Nonreal-time save output history','off')
set_param(sys,'Nonreal-time save scope blocks','off')
set_param(sys,'Nonreal-time save time history','off')
add_block('built-in/S-Function',[sys,'/',['Triggered read',13,'from file']])
set_param([sys,'/',['Triggered read',13,'from file']],...
'hide name',0,...
'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:|Cyclic control (1: cyclic 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','''test1.dat''\/''integer''\/0\/1\/0\/.3\/',...
'position',[140,33,220,77])
add_block('built-in/S-Function',[sys,'/',['Integer scalar',13,'to vector']])
set_param([sys,'/',['Integer scalar',13,'to vector']],...
'hide name',0,...
'function name','simde2bi',...
'parameters','len, p',...
'Mask Display','Sca to vec\nconverter',...
'Mask Type','Decimal to base M vector')
set_param([sys,'/',['Integer scalar',13,'to vector']],...
'Mask Dialogue','Convert decimal integer input to base M\ninteger and output each position of the\nconverted integer using output vector.|Output vector length:|Conversion base M:')
set_param([sys,'/',['Integer scalar',13,'to vector']],...
'Mask Translate','len=@1;p=@2;')
set_param([sys,'/',['Integer scalar',13,'to vector']],...
'Mask Help','This block converts decimal integer scalar input to a base M integer. M must be a\npositive integer. The block outputs the base M integer using a vector. The 1st element in the output vector contains the 1''s position. The 2nd element in the output vector contains the M''s position, and so on. The output vector length is given by setting the parameter entry.')
set_param([sys,'/',['Integer scalar',13,'to vector']],...
'Mask Entries','2\/2\/',...
'position',[250,33,330,77])
add_block('built-in/Demux',[sys,'/','Demux1'])
set_param([sys,'/','Demux1'],...
'hide name',0,...
'outputs','2',...
'position',[350,35,395,70])
% Subsystem ['Binary vector',13,'convol encode'].
new_system([sys,'/',['Binary vector',13,'convol encode']])
set_param([sys,'/',['Binary vector',13,'convol encode']],'Location',[268,346,980,597])
add_block('built-in/State-Space',[sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain3']])
set_param([sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain3']],...
'A','[]',...
'B','[]',...
'C','[]',...
'D','K',...
'Mask Display','D',...
'Mask Type','Matrix Gain',...
'Mask Dialogue','Matrix Gain.|Gain matrix:')
set_param([sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain3']],...
'Mask Translate','K = @1;',...
'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).',...
'Mask Entries','d\/')
set_param([sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain3']],...
'position',[250,6,275,34])
add_block('built-in/State-Space',[sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain']])
set_param([sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain']],...
'orientation',2,...
'A','[]',...
'B','[]',...
'C','[]',...
'D','K',...
'Mask Display','A',...
'Mask Type','Matrix Gain')
set_param([sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain']],...
'Mask Dialogue','Matrix Gain.|Gain matrix:',...
'Mask Translate','K = @1;')
set_param([sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain']],...
'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).',...
'Mask Entries','a\/',...
'position',[240,170,270,200])
add_block('built-in/Inport',[sys,'/',['Binary vector',13,'convol encode/in_1']])
set_param([sys,'/',['Binary vector',13,'convol encode/in_1']],...
'position',[25,60,45,80])
add_block('built-in/State-Space',[sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain1']])
set_param([sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain1']],...
'A','[]',...
'B','[]',...
'C','[]',...
'D','K',...
'Mask Display','B',...
'Mask Type','Matrix Gain',...
'Mask Dialogue','Matrix Gain.|Gain matrix:')
set_param([sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain1']],...
'Mask Translate','K = @1;',...
'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).',...
'Mask Entries','b\/')
set_param([sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain1']],...
'position',[100,56,125,84])
add_block('built-in/Sum',[sys,'/',['Binary vector',13,'convol encode/Sum']])
set_param([sys,'/',['Binary vector',13,'convol encode/Sum']],...
'position',[155,65,175,85])
add_block('built-in/S-Function',[sys,'/',['Binary vector',13,'convol encode/Modulo',13,'operation1']])
set_param([sys,'/',['Binary vector',13,'convol encode/Modulo',13,'operation1']],...
'ForeGround',3,...
'function name','arymodu',...
'parameters','md',...
'Mask Display','Modulo',...
'Mask Type','Modulo')
set_param([sys,'/',['Binary vector',13,'convol encode/Modulo',13,'operation1']],...
'Mask Dialogue','Modulus operation:|Modulus base:',...
'Mask Translate','md = @1;')
set_param([sys,'/',['Binary vector',13,'convol encode/Modulo',13,'operation1']],...
'Mask Help','This block output modulus operation of the input signal with module base as specified in block entry. The length of the output vector is the same as the input vector.')
set_param([sys,'/',['Binary vector',13,'convol encode/Modulo',13,'operation1']],...
'Mask Entries','2\/',...
'position',[345,70,390,100])
add_block('built-in/Sum',[sys,'/',['Binary vector',13,'convol encode/Sum1']])
set_param([sys,'/',['Binary vector',13,'convol encode/Sum1']],...
'position',[465,70,485,90])
add_block('built-in/S-Function',[sys,'/',['Binary vector',13,'convol encode/Modulo',13,'operation']])
set_param([sys,'/',['Binary vector',13,'convol encode/Modulo',13,'operation']],...
'ForeGround',3,...
'function name','arymodu',...
'parameters','md',...
'Mask Display','Modulo',...
'Mask Type','Modulo')
set_param([sys,'/',['Binary vector',13,'convol encode/Modulo',13,'operation']],...
'Mask Dialogue','Modulus operation:|Modulus base:',...
'Mask Translate','md = @1;')
set_param([sys,'/',['Binary vector',13,'convol encode/Modulo',13,'operation']],...
'Mask Help','This block output modulus operation of the input signal with module base as specified in block entry. The length of the output vector is the same as the input vector.')
set_param([sys,'/',['Binary vector',13,'convol encode/Modulo',13,'operation']],...
'Mask Entries','2\/',...
'position',[500,65,545,95])
add_block('built-in/Memory',[sys,'/',['Binary vector',13,'convol encode/Memory1']])
set_param([sys,'/',['Binary vector',13,'convol encode/Memory1']],...
'orientation',2,...
'ForeGround',2,...
'x0','zeros(1,n)',...
'position',[610,135,650,165])
add_block('built-in/Switch',[sys,'/',['Binary vector',13,'convol encode/Switch1']])
set_param([sys,'/',['Binary vector',13,'convol encode/Switch1']],...
'Threshold','.1',...
'position',[610,74,640,106])
add_block('built-in/Outport',[sys,'/',['Binary vector',13,'convol encode/out_1']])
set_param([sys,'/',['Binary vector',13,'convol encode/out_1']],...
'position',[690,80,710,100])
add_block('built-in/State-Space',[sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain2']])
set_param([sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain2']],...
'A','[]',...
'B','[]',...
'C','[]',...
'D','K',...
'Mask Display','C',...
'Mask Type','Matrix Gain',...
'Mask Dialogue','Matrix Gain.|Gain matrix:')
set_param([sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain2']],...
'Mask Translate','K = @1;',...
'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).',...
'Mask Entries','c\/')
set_param([sys,'/',['Binary vector',13,'convol encode/Matrix',13,'Gain2']],...
'position',[420,71,445,99])
% Subsystem ['Binary vector',13,'convol encode/Rising edge',13,'detector'].
new_system([sys,'/',['Binary vector',13,'convol encode/Rising edge',13,'detector']])
set_param([sys,'/',['Binary vector',13,'convol encode/Rising edge',13,'detector']],'Location',[282,116,671,290])
add_block('built-in/Outport',[sys,'/',['Binary vector',13,'convol encode/Rising edge',13,'detector/out_1']])
set_param([sys,'/',['Binary vector',13,'convol encode/Rising edge',13,'detector/out_1']],...
'position',[340,25,360,45])
add_block('built-in/Relational Operator',[sys,'/',['Binary vector',13,'convol encode/Rising edge',13,'detector/Relational',13,'Operator1']])
set_param([sys,'/',['Binary vector',13,'convol encode/Rising edge',13,'detector/Relational',13,'Operator1']],...
'position',[200,88,230,112])
add_block('built-in/Relational Operator',[sys,'/',['Binary vector',13,'convol encode/Rising edge',13,'detector/Relational',13,'Operator2']])
set_param([sys,'/',['Binary vector',13,'convol encode/Rising edge',13,'detector/Relational',13,'Operator2']],...
'Operator','>',...
'position',[265,23,295,47])
add_block('built-in/Constant',[sys,'/',['Binary vector',13,'convol encode/Rising edge',13,'detector/one1']])
set_param([sys,'/',['Binary vector',13,'convol encode/Rising edge',13,'detector/one1']],...
'Value','thld',...
'position',[30,135,60,155])
add_block('built-in/Memory',[sys,'/',['Binary vector',13,'convol encode/Rising edge',13,'detector/Memory1']])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -