⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tutbchcd.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 2 页
字号:
set_param([sys,'/',['Binary vector',13,'BCH decode/out_1']],...
		'position',[495,30,515,50])

add_block('built-in/Outport',[sys,'/',['Binary vector',13,'BCH decode/out_2']])
set_param([sys,'/',['Binary vector',13,'BCH decode/out_2']],...
		'Port','2',...
		'position',[495,95,515,115])
add_line([sys,'/',['Binary vector',13,'BCH decode']],[330,60;390,60])
add_line([sys,'/',['Binary vector',13,'BCH decode']],[360,60;360,110;340,110])
add_line([sys,'/',['Binary vector',13,'BCH decode']],[290,110;255,110;255,70;290,70])
add_line([sys,'/',['Binary vector',13,'BCH decode']],[240,30;255,30;255,50;290,50])
add_line([sys,'/',['Binary vector',13,'BCH decode']],[45,25;60,25;60,50;75,50])
add_line([sys,'/',['Binary vector',13,'BCH decode']],[120,60;150,60;150,30;165,30])
add_line([sys,'/',['Binary vector',13,'BCH decode']],[35,110;200,110;200,60;290,60])
add_line([sys,'/',['Binary vector',13,'BCH decode']],[60,110;60,65;75,65])
add_line([sys,'/',['Binary vector',13,'BCH decode']],[440,50;455,50;455,40;490,40])
add_line([sys,'/',['Binary vector',13,'BCH decode']],[440,65;455,65;455,105;490,105])
set_param([sys,'/',['Binary vector',13,'BCH decode']],...
		'Mask Display','plot(0,0,100,100,x,y,v,w);BCH de',...
		'Mask Type','Vector I/O BCH decode')
set_param([sys,'/',['Binary vector',13,'BCH decode']],...
		'Mask Dialogue','BCH decode with input codeword vector\nlength N, output message vector length K, and error-correction capability T. (N,K,T) must be a valid BCH code combination.|Codeword length N (N=2^M-1. M is a >2 integer):|Message length K (check BCHPOLY for valid K):|Error-correction capability T (0 for unknown):')
set_param([sys,'/',['Binary vector',13,'BCH decode']],...
		'Mask Translate','n=@1;k=@2;t=@3;if t<=0, [x1,x2,x3,x4,t]=bchpoly(n,k);end;dim=3;pow_dim=7;while pow_dim<n,dim=dim+1;pow_dim=2^dim-1;end;tp=gftuple([-1:n-1]'',dim);[x,y]=codeicon(2);[v,w]=trigicon(0,25,get_param(gcb,''orientation''));')
set_param([sys,'/',['Binary vector',13,'BCH decode']],...
		'Mask Help','This block decodes length N binary vector codeword input into length K binary vector message output using BCH code. The block refreshes its decoding output when the enable signal at the second inport has positive value. The second outport outputs the number of errors detected in the process. A negative value indicates the block found more error in the codeword than T.')
set_param([sys,'/',['Binary vector',13,'BCH decode']],...
		'Mask Entries','15\/5\/3\/')


%     Finished composite block ['Binary vector',13,'BCH decode'].

set_param([sys,'/',['Binary vector',13,'BCH decode']],...
		'hide name',0,...
		'position',[355,78,435,122])


%     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','4\/10\/0\/1\/')


%     Finished composite block 'Error rate1'.

set_param([sys,'/','Error rate1'],...
		'hide name',0,...
		'position',[565,33,645,77])

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',[455,68,535,112])

add_block('built-in/S-Function',[sys,'/',['Integer vector',13,'to scalar']])
set_param([sys,'/',['Integer vector',13,'to scalar']],...
		'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 scalar']],...
		'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 scalar']],...
		'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 scalar']],...
		'Mask Entries','2\/',...
		'position',[290,23,370,67])


%     Subsystem  ['Binary error',13,'channel'].

new_system([sys,'/',['Binary error',13,'channel']])
set_param([sys,'/',['Binary error',13,'channel']],'Location',[154,494,633,699])

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])


%     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',[40,94,115,136])

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']],[120,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','0.03\/15\/')


%     Finished composite block ['Binary error',13,'channel'].

set_param([sys,'/',['Binary error',13,'channel']],...
		'hide name',0,...
		'position',[220,78,300,122])
add_line(sys,[95,100;115,100])
add_line(sys,[205,100;215,100])
add_line(sys,[305,90;350,90])
add_line(sys,[340,110;350,110])
add_line(sys,[440,90;450,90])
add_line(sys,[375,45;560,45])
add_line(sys,[540,90;545,90;545,65;560,65])
add_line(sys,[105,100;105,45;285,45])

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 + -