📄 tstrand.m
字号:
function [ret,x0,str,ts,xts]=tstrand(t,x,u,flag);
%TSTRAND is the M-file description of the SIMULINK system named TSTRAND.
% The block-diagram can be displayed by typing: TSTRAND.
%
% SYS=TSTRAND(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 TSTRAND 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 TSTRAND with a FLAG of zero:
% [SIZES]=TSTRAND([],[],[],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',[409,370,909,670])
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', '')
% Subsystem ['Uniform',13,'noise'].
new_system([sys,'/',['Uniform',13,'noise']])
set_param([sys,'/',['Uniform',13,'noise']],'Location',[420,594,637,734])
add_block('built-in/Outport',[sys,'/',['Uniform',13,'noise/out_1']])
set_param([sys,'/',['Uniform',13,'noise/out_1']],...
'position',[165,65,185,85])
add_block('built-in/S-Function',[sys,'/',['Uniform',13,'noise/Uniform',13,'noise']])
set_param([sys,'/',['Uniform',13,'noise/Uniform',13,'noise']],...
'function name','surandom',...
'parameters','seed,up,low',...
'position',[65,55,135,95])
add_line([sys,'/',['Uniform',13,'noise']],[140,75;160,75])
set_param([sys,'/',['Uniform',13,'noise']],...
'Mask Display','Uniform\nnoise',...
'Mask Type','Uniform distribution noise.',...
'Mask Dialogue','Uniform distribution noise.|Low bound of the output:|Upper bound of the output:|Seed:')
set_param([sys,'/',['Uniform',13,'noise']],...
'Mask Translate','seed=@3;up=@2;low=@1;')
set_param([sys,'/',['Uniform',13,'noise']],...
'Mask Help','The output of this block is uniformly distributed between the low and up boundaries. The output size is the same as the vector size for seed.',...
'Mask Entries','0\/1\/1234\/')
% Finished composite block ['Uniform',13,'noise'].
set_param([sys,'/',['Uniform',13,'noise']],...
'position',[55,4,130,46])
% Subsystem ['Gaussian',13,'noise'].
new_system([sys,'/',['Gaussian',13,'noise']])
set_param([sys,'/',['Gaussian',13,'noise']],'Location',[371,386,719,591])
add_block('built-in/State-Space',[sys,'/',['Gaussian',13,'noise/Matrix',13,'Gain']])
set_param([sys,'/',['Gaussian',13,'noise/Matrix',13,'Gain']],...
'A','[]',...
'B','[]',...
'C','[]',...
'D','K',...
'Mask Display','K',...
'Mask Type','Matrix Gain',...
'Mask Dialogue','Matrix Gain.|Gain matrix:')
set_param([sys,'/',['Gaussian',13,'noise/Matrix',13,'Gain']],...
'Mask Translate','K = @1;',...
'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).',...
'Mask Entries','d\/')
set_param([sys,'/',['Gaussian',13,'noise/Matrix',13,'Gain']],...
'position',[210,81,235,109])
add_block('built-in/Outport',[sys,'/',['Gaussian',13,'noise/out_1']])
set_param([sys,'/',['Gaussian',13,'noise/out_1']],...
'position',[295,85,315,105])
add_block('built-in/Sum',[sys,'/',['Gaussian',13,'noise/Sum']])
set_param([sys,'/',['Gaussian',13,'noise/Sum']],...
'position',[140,85,160,105])
add_block('built-in/Constant',[sys,'/',['Gaussian',13,'noise/Constant']])
set_param([sys,'/',['Gaussian',13,'noise/Constant']],...
'Value','m',...
'position',[55,55,75,75])
add_block('built-in/White Noise',[sys,'/',['Gaussian',13,'noise/Random',13,'Number']])
set_param([sys,'/',['Gaussian',13,'noise/Random',13,'Number']],...
'Seed','s',...
'position',[45,102,90,138])
add_line([sys,'/',['Gaussian',13,'noise']],[240,95;290,95])
add_line([sys,'/',['Gaussian',13,'noise']],[165,95;205,95])
add_line([sys,'/',['Gaussian',13,'noise']],[95,120;110,120;110,100;135,100])
add_line([sys,'/',['Gaussian',13,'noise']],[80,65;110,65;110,90;135,90])
set_param([sys,'/',['Gaussian',13,'noise']],...
'Mask Display','Gaussian\nnoise',...
'Mask Type','Gaussian noise.',...
'Mask Dialogue','Gaussian distribution noise.|Mean value:|Standard deviation:|Initial Seed(s):')
set_param([sys,'/',['Gaussian',13,'noise']],...
'Mask Translate','m=@1;d=@2;s=@3;[m,d,s]=gwnoise(m,d,s);')
set_param([sys,'/',['Gaussian',13,'noise']],...
'Mask Help','When the mean value, seed are vectors, the output of this block is a vector with the length of the vector same as the length of mean value vector or that of the seed.')
set_param([sys,'/',['Gaussian',13,'noise']],...
'Mask Entries','0\/1\/4321\/')
% Finished composite block ['Gaussian',13,'noise'].
set_param([sys,'/',['Gaussian',13,'noise']],...
'position',[60,75,135,115])
% Subsystem ['Random-integer',13,'generator1'].
new_system([sys,'/',['Random-integer',13,'generator1']])
set_param([sys,'/',['Random-integer',13,'generator1']],'Location',[98,518,454,687])
add_block('built-in/S-Function',[sys,'/',['Random-integer',13,'generator1/Uniform',13,'number']])
set_param([sys,'/',['Random-integer',13,'generator1/Uniform',13,'number']],...
'function name','srandint',...
'parameters','seed,mul',...
'position',[65,45,135,85])
add_block('built-in/Outport',[sys,'/',['Random-integer',13,'generator1/out_1']])
set_param([sys,'/',['Random-integer',13,'generator1/out_1']],...
'position',[165,55,185,75])
add_line([sys,'/',['Random-integer',13,'generator1']],[140,65;160,65])
set_param([sys,'/',['Random-integer',13,'generator1']],...
'Mask Display','Random\nNumber',...
'Mask Type','Random number generator.')
set_param([sys,'/',['Random-integer',13,'generator1']],...
'Mask Dialogue','Randomly generate integers in the range of [0,1,...,N-1]. N is the M-ary number defined below:|M-ary number:|Seed(s):',...
'Mask Translate','seed=@2;mul=@1;')
set_param([sys,'/',['Random-integer',13,'generator1']],...
'Mask Help','This block generate integer number 0 to M-1, where M is a integer. The probability of the apperance for each number is equal.',...
'Mask Entries','8\/1\/')
% Finished composite block ['Random-integer',13,'generator1'].
set_param([sys,'/',['Random-integer',13,'generator1']],...
'position',[60,143,135,187])
% Subsystem ['Poisson',13,'noise'].
new_system([sys,'/',['Poisson',13,'noise']])
set_param([sys,'/',['Poisson',13,'noise']],'Location',[391,74,676,237])
add_block('built-in/Outport',[sys,'/',['Poisson',13,'noise/out_1']])
set_param([sys,'/',['Poisson',13,'noise/out_1']],...
'position',[165,65,185,85])
add_block('built-in/S-Function',[sys,'/',['Poisson',13,'noise/Poisson distribution',13,'number']])
set_param([sys,'/',['Poisson',13,'noise/Poisson distribution',13,'number']],...
'function name','srandpoi',...
'parameters','seed,lambda',...
'position',[65,55,135,95])
add_line([sys,'/',['Poisson',13,'noise']],[140,75;160,75])
set_param([sys,'/',['Poisson',13,'noise']],...
'Mask Display','Poison\nrand int',...
'Mask Type','Poisson distribution noise.',...
'Mask Dialogue','Poisson distribution number generator.|Lambda:|Seed:')
set_param([sys,'/',['Poisson',13,'noise']],...
'Mask Translate','seed=@2;lambda=@1;')
set_param([sys,'/',['Poisson',13,'noise']],...
'Mask Help','The output of this block is poisson distributed integers. The output size is the same as the vector size for seed. Please use function disttool to see the distribution of the outputof this block.')
set_param([sys,'/',['Poisson',13,'noise']],...
'Mask Entries','.1\/1243\/')
% Finished composite block ['Poisson',13,'noise'].
set_param([sys,'/',['Poisson',13,'noise']],...
'position',[55,219,130,261])
% Subsystem 'Error-Meter'.
new_system([sys,'/','Error-Meter'])
set_param([sys,'/','Error-Meter'],'Location',[255,368,509,510])
add_block('built-in/Inport',[sys,'/','Error-Meter/in_2'])
set_param([sys,'/','Error-Meter/in_2'],...
'Port','2',...
'position',[15,60,35,80])
add_block('built-in/Inport',[sys,'/','Error-Meter/in_1'])
set_param([sys,'/','Error-Meter/in_1'],...
'position',[15,45,35,65])
add_block('built-in/Mux',[sys,'/','Error-Meter/Mux'])
set_param([sys,'/','Error-Meter/Mux'],...
'inputs','2',...
'position',[65,46,100,79])
add_block('built-in/S-Function',[sys,'/','Error-Meter/S-function'])
set_param([sys,'/','Error-Meter/S-function'],...
'function name','sbiterr',...
'parameters','num_lin, K, TDelay, Sample',...
'position',[130,52,195,78])
add_line([sys,'/','Error-Meter'],[40,70;60,70])
add_line([sys,'/','Error-Meter'],[40,55;60,55])
add_line([sys,'/','Error-Meter'],[105,65;125,65])
set_param([sys,'/','Error-Meter'],...
'Mask Display','Error Rate\nMeter',...
'Mask Type','Symbol/Bit Error Counter.')
set_param([sys,'/','Error-Meter'],...
'Mask Dialogue','Compare 2nd port input to scalar 1st port input. Compute the error rate.|Bit per symbol:|Number of digit on display:|Delay between input (1st port) and output (2nd port):|Sampling time (second):')
set_param([sys,'/','Error-Meter'],...
'Mask Translate','K=@1;num_lin=@2;TDelay=@3;Sample=@4;')
set_param([sys,'/','Error-Meter'],...
'Mask Help','The signal from the first port should be always be a scalar. The 2nd port input signal can be a vector with a same time delay to the input signal.',...
'Mask Entries','3\/16\/td\/td\/')
% Finished composite block 'Error-Meter'.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -