📄 tstbchcd.m
字号:
'position',[640,33,720,77])
% Subsystem 'Error rate1'.
new_system([sys,'/','Error rate1'])
set_param([sys,'/','Error rate1'],'Location',[255,368,509,510])
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_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/Mux',[sys,'/','Error rate1/Mux'])
set_param([sys,'/','Error rate1/Mux'],...
'inputs','2',...
'position',[65,46,100,79])
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_line([sys,'/','Error rate1'],[40,70;60,70])
add_line([sys,'/','Error rate1'],[40,55;60,55])
add_line([sys,'/','Error rate1'],[105,65;125,65])
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','K_bch_demo\/20\/0\/1\/')
% Finished composite block 'Error rate1'.
set_param([sys,'/','Error rate1'],...
'hide name',0,...
'position',[760,23,840,67])
% Subsystem ['Max-err lmtd',13,'b-err channel'].
new_system([sys,'/',['Max-err lmtd',13,'b-err channel']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],'Location',[124,322,430,428])
add_block('built-in/Outport',[sys,'/',['Max-err lmtd',13,'b-err channel/out_1']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/out_1']],...
'hide name',0,...
'position',[275,20,295,40])
add_block('built-in/S-Function',[sys,'/',['Max-err lmtd',13,'b-err channel/Mdu']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/Mdu']],...
'hide name',0,...
'function name','arymodu',...
'parameters','md',...
'Mask Display','Modulo',...
'Mask Type','Modulo')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/Mdu']],...
'Mask Dialogue','Modulus operation:|Modulus base:',...
'Mask Translate','md = @1;')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/Mdu']],...
'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,'/',['Max-err lmtd',13,'b-err channel/Mdu']],...
'Mask Entries','2\/',...
'position',[195,11,255,49])
add_block('built-in/Sum',[sys,'/',['Max-err lmtd',13,'b-err channel/S']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/S']],...
'hide name',0,...
'position',[150,20,170,40])
add_block('built-in/Inport',[sys,'/',['Max-err lmtd',13,'b-err channel/in_1']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/in_1']],...
'hide name',0,...
'position',[40,5,60,25])
add_block('built-in/Outport',[sys,'/',['Max-err lmtd',13,'b-err channel/out_2']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/out_2']],...
'hide name',0,...
'Port','2',...
'position',[275,50,295,70])
% Subsystem ['Max-err lmtd',13,'b-err channel/B-n'].
new_system([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],'Location',[36,445,326,560])
add_block('built-in/S-Function',[sys,'/',['Max-err lmtd',13,'b-err channel/B-n/S-function']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n/S-function']],...
'function name','srandbit',...
'parameters','n, prob, seed',...
'position',[90,35,140,55])
add_block('built-in/Outport',[sys,'/',['Max-err lmtd',13,'b-err channel/B-n/out_1']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n/out_1']],...
'position',[190,35,210,55])
add_line([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],[145,45;185,45])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],...
'Mask Display','B-vector\ngenerator',...
'Mask Type','Binary noise generator')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],...
'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,'/',['Max-err lmtd',13,'b-err channel/B-n']],...
'Mask Translate','n=@1;prob=@2;seed=@3;')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],...
'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.')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],...
'Mask Entries','leng\/prob\/seed\/')
% Finished composite block ['Max-err lmtd',13,'b-err channel/B-n'].
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],...
'hide name',0,...
'position',[30,38,110,82])
add_line([sys,'/',['Max-err lmtd',13,'b-err channel']],[175,30;190,30])
add_line([sys,'/',['Max-err lmtd',13,'b-err channel']],[260,30;270,30])
add_line([sys,'/',['Max-err lmtd',13,'b-err channel']],[115,60;130,60;130,35;145,35])
add_line([sys,'/',['Max-err lmtd',13,'b-err channel']],[115,60;270,60])
add_line([sys,'/',['Max-err lmtd',13,'b-err channel']],[65,15;90,15;90,25;145,25])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],...
'Mask Display','plot(0,0,100,100,x,y);Lmtd b-err',...
'Mask Type','Limited binary error channel')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],...
'Mask Dialogue','Add binary errors with specified error\nnumber probability.|Vector length(can''t be changed during simulation):|Probability of one err, two errs, three errs...:|Seed:')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],...
'Mask Translate','leng=@1;prob=@2;seed=@3;[x,y]=chanicon;')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],...
'Mask Help','This block adds binary errors to the input signal. The maximum number of errors added to the signal 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 errors in the vector. The 1st outport is the signal with added noise. The 2nd outport is the added noise.')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],...
'Mask Entries','N_bch_demo\/ones(1,T_bch_demo)/(T_bch_demo+1)\/12345\/')
% Finished composite block ['Max-err lmtd',13,'b-err channel'].
set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],...
'hide name',0,...
'position',[340,43,420,87])
add_block('built-in/Sum',[sys,'/','Sum3'])
set_param([sys,'/','Sum3'],...
'ForeGround',7,...
'hide name',0,...
'inputs','+',...
'position',[545,120,565,140])
add_block('built-in/Mux',[sys,'/','Mux1'])
set_param([sys,'/','Mux1'],...
'hide name',0,...
'inputs','2',...
'position',[675,105,710,140])
% 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','50\/-1.2\/.2+T_bch_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',[770,106,800,144])
add_block('built-in/Constant',[sys,'/','Constant1'])
set_param([sys,'/','Constant1'],...
'hide name',0,...
'position',[480,65,500,85])
% Subsystem ['BCH code',13,'length table'].
new_system([sys,'/',['BCH code',13,'length table']])
set_param([sys,'/',['BCH code',13,'length table']],'Location',[-10,380,117,533])
set_param([sys,'/',['BCH code',13,'length table']],...
'Mask Display','BCH code\nview table',...
'Mask Dialogue','eval(''bchpoly'')')
% Finished composite block ['BCH code',13,'length table'].
set_param([sys,'/',['BCH code',13,'length table']],...
'BackGround',5,...
'hide name',0,...
'position',[255,103,335,147])
add_block('built-in/Note',[sys,'/',['This demo uses the MATLAB workspace variable to set the code world length N_bch_demo=15,',13,'message length K_bch_demo= 5, and error correction capability T_bch_demo=3. ']])
set_param([sys,'/',['This demo uses the MATLAB workspace variable to set the code world length N_bch_demo=15,',13,'message length K_bch_demo= 5, and error correction capability T_bch_demo=3. ']],...
'position',[330,155,335,160])
add_block('built-in/Note',[sys,'/',['Double click "BCH code view table" block to view most frequently used code word length//message',13,'length//error-correction capability table. ']])
set_param([sys,'/',['Double click "BCH code view table" block to view most frequently used code word length//message',13,'length//error-correction capability table. ']],...
'position',[330,190,335,195])
add_line(sys,[725,55;755,55])
add_line(sys,[90,65;115,65])
add_line(sys,[100,65;100,25;740,25;740,35;755,35])
add_line(sys,[615,55;635,55])
add_line(sys,[205,65;215,65])
add_line(sys,[505,75;525,75])
add_line(sys,[715,125;765,125])
add_line(sys,[615,75;625,75;625,115;670,115])
add_line(sys,[570,130;670,130])
add_line(sys,[305,65;335,65])
add_line(sys,[425,55;525,55])
add_line(sys,[425,75;450,75;450,130;540,130])
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 + -