📄 tstrscbv.m
字号:
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 Rate\nMeter',...
'Mask Type','Symbol/Bit Error Counter.')
set_param([sys,'/','Error rate'],...
'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 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 should be always be a scalar. The 2nd port input signal can be a vector with a same time delay to the input signal.')
set_param([sys,'/','Error rate'],...
'Mask Entries','K_rs_demo*M_rs_demo\/20\/0\/1\/')
% Finished composite block 'Error rate'.
set_param([sys,'/','Error rate'],...
'hide name',0,...
'position',[755,13,830,57])
add_block('built-in/S-Function',[sys,'/',['Integer vector',13,'to scalar1']])
set_param([sys,'/',['Integer vector',13,'to scalar1']],...
'hide name',0,...
'function name','simbi2de',...
'parameters','p',...
'Mask Display','Vec to sca\nconverter',...
'Mask Type','Base M vector to decimal integer')
set_param([sys,'/',['Integer vector',13,'to scalar1']],...
'Mask Dialogue','Convert base M integer with each\nposition in the input vector into scalar decimal output.|Input integer base M:',...
'Mask Translate','p=@1;')
set_param([sys,'/',['Integer vector',13,'to scalar1']],...
'Mask Help','This block convert the base M vector into scalar decimal integer output. Each element of the input vector is one position of the digit of the base M integer. The 1st element in the input vector contains the 1''s position. The 2nd element in the input vector contains the M''s position.')
set_param([sys,'/',['Integer vector',13,'to scalar1']],...
'Mask Entries','2\/',...
'position',[640,48,720,92])
add_block('built-in/Constant',[sys,'/','Const2'])
set_param([sys,'/','Const2'],...
'orientation',3,...
'hide name',0,...
'position',[500,120,520,140])
% 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/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_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_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 the probability of "1"s in the vector being specified.|Vector length(can''t be changed during simulation):|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 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','N_rs_demo\/1/2\/12345\/')
% Finished composite block ['Binary vector',13,'noise generator1'].
set_param([sys,'/',['Binary vector',13,'noise generator1']],...
'hide name',0,...
'position',[80,98,160,142])
% Subsystem ['Triggered',13,'signal switch'].
new_system([sys,'/',['Triggered',13,'signal switch']])
set_param([sys,'/',['Triggered',13,'signal switch']],'Location',[672,516,1052,680])
add_block('built-in/S-Function',[sys,'/',['Triggered',13,'signal switch/S-function']])
set_param([sys,'/',['Triggered',13,'signal switch/S-function']],...
'function name','stdmamux',...
'parameters','sw,ke,in,tt',...
'position',[205,60,275,90])
add_block('built-in/Inport',[sys,'/',['Triggered',13,'signal switch/in_2']])
set_param([sys,'/',['Triggered',13,'signal switch/in_2']],...
'Port','2',...
'position',[60,75,80,95])
add_block('built-in/Outport',[sys,'/',['Triggered',13,'signal switch/out_1']])
set_param([sys,'/',['Triggered',13,'signal switch/out_1']],...
'position',[320,65,340,85])
add_block('built-in/Mux',[sys,'/',['Triggered',13,'signal switch/Mux']])
set_param([sys,'/',['Triggered',13,'signal switch/Mux']],...
'inputs','2',...
'position',[145,54,175,96])
add_block('built-in/Inport',[sys,'/',['Triggered',13,'signal switch/in_1']])
set_param([sys,'/',['Triggered',13,'signal switch/in_1']],...
'position',[65,20,85,40])
add_line([sys,'/',['Triggered',13,'signal switch']],[280,75;315,75])
add_line([sys,'/',['Triggered',13,'signal switch']],[180,75;200,75])
add_line([sys,'/',['Triggered',13,'signal switch']],[85,85;140,85])
add_line([sys,'/',['Triggered',13,'signal switch']],[90,30;120,30;120,65;140,65])
set_param([sys,'/',['Triggered',13,'signal switch']],...
'Mask Display','plot(0,0,100,100,v,w);Vct re-arr',...
'Mask Type','Vector signal re-distribution')
set_param([sys,'/',['Triggered',13,'signal switch']],...
'Mask Dialogue','The rising edge from the 2nd inport\ntriggers the output of this block to follow the rule of the next row in the switch box.|Switch box (column number equals block output length):|Keeping value (flag 0 element in switch box):|Initial value (before the 1st trigger is detected):|Trigger threshold:')
set_param([sys,'/',['Triggered',13,'signal switch']],...
'Mask Translate','sw=@1;ke=@2;in=@3;tt=@4;[v,w]=trigicon(0,25,get_param(gcb,''orientation''),2);')
set_param([sys,'/',['Triggered',13,'signal switch']],...
'Mask Help','When the ith element in the current row of the switch box is j, the ith element in the output vector equals jth input element. When j=0, the output keeps the last output value if keep_value >= 0; it equals ini_val otherwise. The switch box column number must be same as the lengths of output, keep_value, and init_value. The rising edge of the 2nd inport triggers the distribution pattern to follow the next row of the switch box.')
set_param([sys,'/',['Triggered',13,'signal switch']],...
'Mask Entries','vec2mat([1:N_rs_demo]''*ones(1,M_rs_demo),M_rs_demo*N_rs_demo)\/zeros(1,N_rs_demo*M_rs_demo)\/zeros(1,N_rs_demo*M_rs_demo)\/.1\/')
% Finished composite block ['Triggered',13,'signal switch'].
set_param([sys,'/',['Triggered',13,'signal switch']],...
'hide name',0,...
'position',[245,108,325,152])
add_block('built-in/Sum',[sys,'/','Sum3'])
set_param([sys,'/','Sum3'],...
'ForeGround',7,...
'hide name',0,...
'inputs','+',...
'position',[435,150,455,170])
add_block('built-in/Mux',[sys,'/','Mux1'])
set_param([sys,'/','Mux1'],...
'hide name',0,...
'inputs','2',...
'position',[665,135,700,170])
% Subsystem ['Compare placed and',13,'detected number of errors'].
new_system([sys,'/',['Compare placed and',13,'detected number of errors']])
set_param([sys,'/',['Compare placed and',13,'detected number of errors']],'Location',[0,59,274,252])
add_block('built-in/Inport',[sys,'/',['Compare placed and',13,'detected number of errors/x']])
set_param([sys,'/',['Compare placed and',13,'detected number of errors/x']],...
'position',[65,55,85,75])
add_block('built-in/S-Function',[sys,'/',['Compare placed and',13,'detected number of errors/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Compare placed and',13,'detected number of errors/S-function',13,'M-file which plots',13,'lines',13,'']],...
'function name','sfuny',...
'parameters','ax, color,dt',...
'position',[130,55,180,75])
add_line([sys,'/',['Compare placed and',13,'detected number of errors']],[90,65;125,65])
set_param([sys,'/',['Compare placed and',13,'detected number of errors']],...
'Mask Display','plot(0,0,100,100,[90,10,10,10,90,90,10],[65,65,90,40,40,90,90],[90,78,69,54,40,31,25,10],[77,60,48,46,56,75,81,84])',...
'Mask Type','Graph scope.')
set_param([sys,'/',['Compare placed and',13,'detected number of errors']],...
'Mask Dialogue','Graph scope using MATLAB graph window.\nEnter plotting ranges and line type.|Time range:|y-min:|y-max:|Line type (rgbw-:*). Seperate each plot by ''/'':')
set_param([sys,'/',['Compare placed and',13,'detected number of errors']],...
'Mask Translate','color = @4; ax = [0, @1, @2, @3]; dt = -1;')
set_param([sys,'/',['Compare placed and',13,'detected number of errors']],...
'Mask Help','This block plots to the MATLAB graph window and can be used as an improved version of the Scope block. Look at the m-file sfuny.m to see how it works. This block can take scalar or vector input signal.')
set_param([sys,'/',['Compare placed and',13,'detected number of errors']],...
'Mask Entries','10\/-1.2\/.2+K_rs_demo\/''mx/c+/m-/w-/b+''\/')
% Finished composite block ['Compare placed and',13,'detected number of errors'].
set_param([sys,'/',['Compare placed and',13,'detected number of errors']],...
'hide name',0,...
'position',[750,136,780,174])
add_block('built-in/Constant',[sys,'/','Const1'])
set_param([sys,'/','Const1'],...
'hide name',0,...
'position',[185,85,205,105])
add_block('built-in/Constant',[sys,'/','Const3'])
set_param([sys,'/','Const3'],...
'hide name',0,...
'position',[200,130,220,150])
add_block('built-in/S-Function',[sys,'/',['Modulo',13,'operation1']])
set_param([sys,'/',['Modulo',13,'operation1']],...
'hide name',0,...
'function name','arymodu',...
'parameters','md',...
'Mask Display','Modulo',...
'Mask Type','Modulo')
set_param([sys,'/',['Modulo',13,'operation1']],...
'Mask Dialogue','Output the remainder of the input value divided by the modulo base.|Modulo base:',...
'Mask Translate','md = @1;')
set_param([sys,'/',['Modulo',13,'operation1']],...
'Mask Help','This block outputs the remainder of the input value divided by the modulo base. The length of the output vector is the same as the input vector.',...
'Mask Entries','2\/')
set_param([sys,'/',['Modulo',13,'operation1']],...
'position',[405,48,485,92])
add_block('built-in/Note',[sys,'/','This demo shows one burst error R-S code correction.'])
set_param([sys,'/','This demo shows one burst error R-S code correction.'],...
'position',[190,170,195,175])
add_block('built-in/Note',[sys,'/',['This demo uses the MATLAB workspace variable to set the code world length N_rs_demo=7,',13,'message length K_rs_demo= 4, and bits per symbol M_rs_demo=3. ']])
set_param([sys,'/',['This demo uses the MATLAB workspace variable to set the code world length N_rs_demo=7,',13,'message length K_rs_demo= 4, and bits per symbol M_rs_demo=3. ']],...
'position',[295,190,300,195])
add_line(sys,[320,65;355,65])
add_line(sys,[385,70;400,70])
add_line(sys,[490,70;535,70])
add_line(sys,[95,55;115,55])
add_line(sys,[205,55;230,55])
add_line(sys,[625,90;625,145;660,145])
add_line(sys,[460,160;660,160])
add_line(sys,[510,115;510,90;535,90])
add_line(sys,[625,70;635,70])
add_line(sys,[725,70;735,70;735,45;750,45])
add_line(sys,[705,155;745,155])
add_line(sys,[105,55;105,25;750,25])
add_line(sys,[165,120;240,120])
add_line(sys,[330,130;335,130;335,75;355,75])
add_line(sys,[190,120;190,160;430,160])
add_line(sys,[210,95;215,95;215,75;230,75])
add_line(sys,[225,140;240,140])
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 + -