📄 tstconsq.m
字号:
function [ret,x0,str,ts,xts]=tstconsq(t,x,u,flag);
%TSTCONSQ is the M-file description of the SIMULINK system named TSTCONSQ.
% The block-diagram can be displayed by typing: TSTCONSQ.
%
% SYS=TSTCONSQ(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 TSTCONSQ 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 TSTCONSQ with a FLAG of zero:
% [SIZES]=TSTCONSQ([],[],[],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',[208,399,797,561])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-45')
set_param(sys,'Start time', '1')
set_param(sys,'Stop time', '999999')
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', '')
set_param(sys,'Load callback','GWN=.02;leng=5;');
% Subsystem ['Binary error',13,'channel'].
new_system([sys,'/',['Binary error',13,'channel']])
set_param([sys,'/',['Binary error',13,'channel']],'Location',[259,203,738,408])
% Subsystem ['Binary error',13,'channel/Poisson',13,'noise'].
new_system([sys,'/',['Binary error',13,'channel/Poisson',13,'noise']])
set_param([sys,'/',['Binary error',13,'channel/Poisson',13,'noise']],'Location',[391,74,676,237])
add_block('built-in/S-Function',[sys,'/',['Binary error',13,'channel/Poisson',13,'noise/Poisson distribution',13,'number']])
set_param([sys,'/',['Binary error',13,'channel/Poisson',13,'noise/Poisson distribution',13,'number']],...
'function name','srandpoi',...
'parameters','seed,lambda',...
'position',[65,55,135,95])
add_block('built-in/Outport',[sys,'/',['Binary error',13,'channel/Poisson',13,'noise/out_1']])
set_param([sys,'/',['Binary error',13,'channel/Poisson',13,'noise/out_1']],...
'position',[165,65,185,85])
add_line([sys,'/',['Binary error',13,'channel/Poisson',13,'noise']],[140,75;160,75])
set_param([sys,'/',['Binary error',13,'channel/Poisson',13,'noise']],...
'Mask Display','Poison\nrand int',...
'Mask Type','Poisson distribution noise.',...
'Mask Dialogue','Poisson distribution number generator.|Lambda:|Seed:')
set_param([sys,'/',['Binary error',13,'channel/Poisson',13,'noise']],...
'Mask Translate','seed=@2;lambda=@1;')
set_param([sys,'/',['Binary error',13,'channel/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,'/',['Binary error',13,'channel/Poisson',13,'noise']],...
'Mask Entries','P\/(randint(1, M)+100)*1000*max(P)\/')
% Finished composite block ['Binary error',13,'channel/Poisson',13,'noise'].
set_param([sys,'/',['Binary error',13,'channel/Poisson',13,'noise']],...
'position',[20,94,95,136])
add_block('built-in/Inport',[sys,'/',['Binary error',13,'channel/in_1']])
set_param([sys,'/',['Binary error',13,'channel/in_1']],...
'position',[95,30,115,50])
add_block('built-in/Outport',[sys,'/',['Binary error',13,'channel/out_1']])
set_param([sys,'/',['Binary error',13,'channel/out_1']],...
'position',[390,65,410,85])
add_block('built-in/Sum',[sys,'/',['Binary error',13,'channel/Sum']])
set_param([sys,'/',['Binary error',13,'channel/Sum']],...
'position',[235,65,255,85])
add_block('built-in/S-Function',[sys,'/',['Binary error',13,'channel/Modulo',13,'operation']])
set_param([sys,'/',['Binary error',13,'channel/Modulo',13,'operation']],...
'function name','arymodu',...
'parameters','md',...
'Mask Display','Modulo',...
'Mask Type','Modulo',...
'Mask Dialogue','Modulo operation:|Modulo base:')
set_param([sys,'/',['Binary error',13,'channel/Modulo',13,'operation']],...
'Mask Translate','md = @1;')
set_param([sys,'/',['Binary error',13,'channel/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 error',13,'channel/Modulo',13,'operation']],...
'Mask Entries','2\/',...
'position',[300,56,360,94])
add_block('built-in/Saturation',[sys,'/',['Binary error',13,'channel/Saturation']])
set_param([sys,'/',['Binary error',13,'channel/Saturation']],...
'Lower Limit','0',...
'Upper Limit','1',...
'position',[165,70,190,90])
add_block('built-in/Outport',[sys,'/',['Binary error',13,'channel/out_2']])
set_param([sys,'/',['Binary error',13,'channel/out_2']],...
'Port','2',...
'position',[275,125,295,145])
add_line([sys,'/',['Binary error',13,'channel']],[365,75;385,75])
add_line([sys,'/',['Binary error',13,'channel']],[120,40;210,40;210,70;230,70])
add_line([sys,'/',['Binary error',13,'channel']],[100,115;140,115;140,80;160,80])
add_line([sys,'/',['Binary error',13,'channel']],[260,75;295,75])
add_line([sys,'/',['Binary error',13,'channel']],[195,80;230,80])
add_line([sys,'/',['Binary error',13,'channel']],[210,80;210,135;270,135])
set_param([sys,'/',['Binary error',13,'channel']],...
'Mask Display','plot(0,0,100,100,x,y);B-error',...
'Mask Type','Add binary errors')
set_param([sys,'/',['Binary error',13,'channel']],...
'Mask Dialogue','The error probability can be a scalar or a vector with the same length as the\ninput vector length.|Error probability:|Input vector length:')
set_param([sys,'/',['Binary error',13,'channel']],...
'Mask Translate','M=@2;P=@1;if length(P)~=M,P=ones(1,M)*P(1);end;[x,y]=chanicon;')
set_param([sys,'/',['Binary error',13,'channel']],...
'Mask Help','This block adds binary errors to transmitted binary signals. The error probability is given in the parameter setting. The first output port outputs the transmitting signal (after adding noise). The second port outputs the errors signal added to the transmitting signal.')
set_param([sys,'/',['Binary error',13,'channel']],...
'Mask Entries','.01\/1\/')
% Finished composite block ['Binary error',13,'channel'].
set_param([sys,'/',['Binary error',13,'channel']],...
'hide name',0,...
'position',[250,68,330,112])
% Subsystem 'Error rate1'.
new_system([sys,'/','Error rate1'])
set_param([sys,'/','Error rate1'],'Location',[255,368,509,510])
add_block('built-in/S-Function',[sys,'/','Error rate1/S-function'])
set_param([sys,'/','Error rate1/S-function'],...
'function name','sbiterr',...
'parameters','num_lin, K, TDelay, Sample',...
'position',[130,52,195,78])
add_block('built-in/Mux',[sys,'/','Error rate1/Mux'])
set_param([sys,'/','Error rate1/Mux'],...
'inputs','2',...
'position',[65,46,100,79])
add_block('built-in/Inport',[sys,'/','Error rate1/in_1'])
set_param([sys,'/','Error rate1/in_1'],...
'position',[15,45,35,65])
add_block('built-in/Inport',[sys,'/','Error rate1/in_2'])
set_param([sys,'/','Error rate1/in_2'],...
'Port','2',...
'position',[15,60,35,80])
add_line([sys,'/','Error rate1'],[105,65;125,65])
add_line([sys,'/','Error rate1'],[40,55;60,55])
add_line([sys,'/','Error rate1'],[40,70;60,70])
set_param([sys,'/','Error rate1'],...
'Mask Display','Error\nmeter',...
'Mask Type','Symbol/bit error counter')
set_param([sys,'/','Error rate1'],...
'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 rate1'],...
'Mask Translate','K=@1;num_lin=@2;TDelay=@3;Sample=@4;')
set_param([sys,'/','Error rate1'],...
'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 rate1'],...
'Mask Entries','1\/20\/leng+2\/1/tf(2,size(tf,2))\/')
% Finished composite block 'Error rate1'.
set_param([sys,'/','Error rate1'],...
'hide name',0,...
'position',[490,38,570,82])
% Subsystem ['Sampled read with',13,'synchronized pulse'].
new_system([sys,'/',['Sampled read with',13,'synchronized pulse']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse']],'Location',[355,527,737,674])
% Subsystem ['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1'].
new_system([sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1']])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -