📄 tbrand.m
字号:
function [ret,x0,str,ts,xts]=tbrand(t,x,u,flag);
%TBRAND is the M-file description of the SIMULINK system named TBRAND.
% The block-diagram can be displayed by typing: TBRAND.
%
% SYS=TBRAND(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 TBRAND 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 TBRAND with a FLAG of zero:
% [SIZES]=TBRAND([],[],[],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',[40,221,426,317])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-45')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '999')
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 'Error rate'.
new_system([sys,'/','Error rate'])
set_param([sys,'/','Error rate'],'Location',[255,368,509,510])
add_block('built-in/S-Function',[sys,'/','Error rate/S-function'])
set_param([sys,'/','Error rate/S-function'],...
'function name','sbiterr',...
'parameters','num_lin, K, TDelay, Sample',...
'position',[130,52,195,78])
add_block('built-in/Mux',[sys,'/','Error rate/Mux'])
set_param([sys,'/','Error rate/Mux'],...
'inputs','2',...
'position',[65,46,100,79])
add_block('built-in/Inport',[sys,'/','Error rate/in_1'])
set_param([sys,'/','Error rate/in_1'],...
'position',[15,45,35,65])
add_block('built-in/Inport',[sys,'/','Error rate/in_2'])
set_param([sys,'/','Error rate/in_2'],...
'Port','2',...
'position',[15,60,35,80])
add_line([sys,'/','Error rate'],[105,65;125,65])
add_line([sys,'/','Error rate'],[40,55;60,55])
add_line([sys,'/','Error rate'],[40,70;60,70])
set_param([sys,'/','Error rate'],...
'Mask Display','Error\nmeter',...
'Mask Type','Symbol/bit error counter')
set_param([sys,'/','Error rate'],...
'Mask Dialogue','Use the input data from the 1st port as the reference signal to detect the number of errors and error rate of the 2nd port inputted signal.|Bit per symbol:|Number of digits on display:|Delay between input (1st port) and output (2nd port):|Sampling time (sec):')
set_param([sys,'/','Error rate'],...
'Mask Translate','K=@1;num_lin=@2;TDelay=@3;Sample=@4;')
set_param([sys,'/','Error rate'],...
'Mask Help','The signal from the first port must be a scalar. The second input port can be a vector with a same-time delay to the input signal. The comparison happens only at the sampling point.')
set_param([sys,'/','Error rate'],...
'Mask Entries','1\/16\/0\/.1\/')
% Finished composite block 'Error rate'.
set_param([sys,'/','Error rate'],...
'hide name',0,...
'position',[275,18,355,62])
add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
'hide name',0,...
'inputs','2',...
'position',[215,31,250,64])
add_block('built-in/Sum',[sys,'/','Sum'])
set_param([sys,'/','Sum'],...
'hide name',0,...
'inputs','+',...
'position',[155,45,175,65])
% Subsystem ['Binary vector',13,'noise generator1'].
new_system([sys,'/',['Binary vector',13,'noise generator1']])
set_param([sys,'/',['Binary vector',13,'noise generator1']],'Location',[36,445,326,560])
add_block('built-in/Outport',[sys,'/',['Binary vector',13,'noise generator1/out_1']])
set_param([sys,'/',['Binary vector',13,'noise generator1/out_1']],...
'position',[190,35,210,55])
add_block('built-in/S-Function',[sys,'/',['Binary vector',13,'noise generator1/S-function']])
set_param([sys,'/',['Binary vector',13,'noise generator1/S-function']],...
'function name','srandbit',...
'parameters','n, prob, seed',...
'position',[90,35,140,55])
add_line([sys,'/',['Binary vector',13,'noise generator1']],[145,45;185,45])
set_param([sys,'/',['Binary vector',13,'noise generator1']],...
'Mask Display','plot(0,0,100,100,x,y);B-vector',...
'Mask Type','Binary noise generator')
set_param([sys,'/',['Binary vector',13,'noise generator1']],...
'Mask Dialogue','Generate a binary vector with control over the number of "1"s.|Binary vector length:|Probability of a "one", two "ones",three "ones"...:|Seed:')
set_param([sys,'/',['Binary vector',13,'noise generator1']],...
'Mask Translate','n=@1;prob=@2;seed=@3;[x,y]=srcsicon(5);')
set_param([sys,'/',['Binary vector',13,'noise generator1']],...
'Mask Help','This block outputs a zero vector with "1"s randomly distributed the vector. The maximum number of "1"s in the vector is the same as the length of the vector probability. The value of the ith element of the probability is the probability of i number of "1"s in the vector, e.g. [1/4 1/4 1/4] means probability of single "1", double "1"s, three "1"s or no "1" in the vector is 1/4.')
set_param([sys,'/',['Binary vector',13,'noise generator1']],...
'Mask Entries','3\/1/2\/12345\/')
% Finished composite block ['Binary vector',13,'noise generator1'].
set_param([sys,'/',['Binary vector',13,'noise generator1']],...
'position',[20,33,100,77])
add_line(sys,[105,55;150,55])
add_line(sys,[180,55;210,55])
add_line(sys,[115,55;115,40;210,40])
add_line(sys,[255,50;270,50])
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 + -