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

📄 concdrtw.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 3 页
字号:
add_line([sys,'/',['Binary error',13,'channel']],[365,75;385,75])
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.02\/3\/')


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

set_param([sys,'/',['Binary error',13,'channel']],...
		'hide name',0,...
		'position',[450,58,530,102])


%     Subsystem  ['Binary vector',13,'convol decode1'].

new_system([sys,'/',['Binary vector',13,'convol decode1']])
set_param([sys,'/',['Binary vector',13,'convol decode1']],'Location',[719,297,1227,483])

add_block('built-in/Inport',[sys,'/',['Binary vector',13,'convol decode1/in_2']])
set_param([sys,'/',['Binary vector',13,'convol decode1/in_2']],...
		'Port','2',...
		'position',[30,120,50,140])

add_block('built-in/Demux',[sys,'/',['Binary vector',13,'convol decode1/Demux']])
set_param([sys,'/',['Binary vector',13,'convol decode1/Demux']],...
		'outputs','[tf(2,size(tf,2)), 1]',...
		'position',[305,35,345,70])

add_block('built-in/Outport',[sys,'/',['Binary vector',13,'convol decode1/out_1']])
set_param([sys,'/',['Binary vector',13,'convol decode1/out_1']],...
		'position',[405,35,425,55])

add_block('built-in/Outport',[sys,'/',['Binary vector',13,'convol decode1/out_2']])
set_param([sys,'/',['Binary vector',13,'convol decode1/out_2']],...
		'Port','2',...
		'position',[445,65,465,85])

add_block('built-in/S-Function',[sys,'/',['Binary vector',13,'convol decode1/Modulo',13,'operation1']])
set_param([sys,'/',['Binary vector',13,'convol decode1/Modulo',13,'operation1']],...
		'function name','sviterbi',...
		'parameters','tf, leng, tran_prob, plot_flag,v1,v2,v3,v4',...
		'position',[235,40,280,70])

add_block('built-in/Mux',[sys,'/',['Binary vector',13,'convol decode1/Mux']])
set_param([sys,'/',['Binary vector',13,'convol decode1/Mux']],...
		'inputs','[tf(1,size(tf,2)), 1]',...
		'Mask Display','',...
		'position',[170,36,205,69])


%     Subsystem  ['Binary vector',13,'convol decode1/Rising edge',13,'detector'].

new_system([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']])
set_param([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']],'Location',[282,116,671,290])

add_block('built-in/Outport',[sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/out_1']])
set_param([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/out_1']],...
		'position',[340,25,360,45])

add_block('built-in/Relational Operator',[sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/Relational',13,'Operator1']])
set_param([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/Relational',13,'Operator1']],...
		'position',[200,88,230,112])

add_block('built-in/Relational Operator',[sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/Relational',13,'Operator2']])
set_param([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/Relational',13,'Operator2']],...
		'Operator','>',...
		'position',[265,23,295,47])

add_block('built-in/Constant',[sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/one1']])
set_param([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/one1']],...
		'Value','thld',...
		'position',[30,135,60,155])

add_block('built-in/Memory',[sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/Memory1']])
set_param([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/Memory1']],...
		'position',[125,80,165,110])

add_block('built-in/Inport',[sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/in_1']])
set_param([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/in_1']],...
		'position',[10,15,30,35])

add_block('built-in/Relational Operator',[sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/Relational',13,'Operator']])
set_param([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector/Relational',13,'Operator']],...
		'position',[135,18,165,42])
add_line([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']],[35,25;130,25])
add_line([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']],[45,25;45,95;120,95])
add_line([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']],[170,95;195,95])
add_line([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']],[65,145;100,145;100,35;130,35])
add_line([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']],[100,145;180,145;180,105;195,105])
add_line([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']],[170,30;260,30])
add_line([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']],[235,100;240,100;240,40;260,40])
add_line([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']],[300,35;335,35])
set_param([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']],...
		'Mask Display','Edge\nDetector',...
		'Mask Type','Edge Detection',...
		'Mask Dialogue','Rising edge detection:|Threshold:')
set_param([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']],...
		'Mask Translate','thld=@1;',...
		'Mask Help','When the input signal rising edge passed the given shreshold, this block outputs one, otherwise outputs zero.')
set_param([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']],...
		'Mask Entries','thd\/')


%     Finished composite block ['Binary vector',13,'convol decode1/Rising edge',13,'detector'].

set_param([sys,'/',['Binary vector',13,'convol decode1/Rising edge',13,'detector']],...
		'position',[75,112,130,148])

add_block('built-in/Inport',[sys,'/',['Binary vector',13,'convol decode1/in_1']])
set_param([sys,'/',['Binary vector',13,'convol decode1/in_1']],...
		'position',[65,35,85,55])
add_line([sys,'/',['Binary vector',13,'convol decode1']],[135,130;140,130;140,60;165,60])
add_line([sys,'/',['Binary vector',13,'convol decode1']],[90,45;165,45])
add_line([sys,'/',['Binary vector',13,'convol decode1']],[210,55;230,55])
add_line([sys,'/',['Binary vector',13,'convol decode1']],[350,60;375,60;375,75;440,75])
add_line([sys,'/',['Binary vector',13,'convol decode1']],[350,45;400,45])
add_line([sys,'/',['Binary vector',13,'convol decode1']],[285,55;300,55])
add_line([sys,'/',['Binary vector',13,'convol decode1']],[55,130;70,130])
set_param([sys,'/',['Binary vector',13,'convol decode1']],...
		'Mask Display','plot(0,0,100,100,x,y,v,w);Convl de',...
		'Mask Type','Vector I/O convolution decode')
set_param([sys,'/',['Binary vector',13,'convol decode1']],...
		'Mask Dialogue','Convolution decode with codeword length\nN and message length K. Transfer function\nmatrix is a K-by-N matrix.|Transfer function (or SIMULINK diagram):|Path memory length (delay=path_length*K*T_out):|Transfer probability (3 row matrix, 0 for hard decision):|Trellis figure plot length (0 for no plot):|Trigger signal threshold:')
set_param([sys,'/',['Binary vector',13,'convol decode1']],...
		'Mask Translate','gen=@1;leng=@2;tran_prob=@3;plot_flag=@4;thd=@5;[tf,v2,v3,v4,v5,v6,M,nss]=simviter(gen);[x,y]=codeicon(2);[v,w]=trigicon(0,25,get_param(gcb,''orientation''),2);v1=zeros(7,1);v2=zeros(nss,1);v3=zeros(nss^2*leng,1);v4=zeros(nss,1);tf=simviter(gen);')
set_param([sys,'/',['Binary vector',13,'convol decode1']],...
		'Mask Help','This block decodes length N binary vector convolution code codeword into length K binary vector message using Viterbi algorithm. The block refreshes its register memory and decoding output at the rising edge of the second inport pulse. The second outport outputs the metric value for soft decision or the accumulative distance for hard\ndecision.')
set_param([sys,'/',['Binary vector',13,'convol decode1']],...
		'Mask Entries','[ 0  0  1   1   3;1 0 1 0 2; 0 0 1 0 2; 0 0 0 1 0;0 1 1 1 -Inf]\/10\/0\/0\/.5\/')


%     Finished composite block ['Binary vector',13,'convol decode1'].

set_param([sys,'/',['Binary vector',13,'convol decode1']],...
		'hide name',0,...
		'position',[560,58,640,102])


%     Subsystem  ['Sampled read with',13,'synchronized pulse1'].

new_system([sys,'/',['Sampled read with',13,'synchronized pulse1']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1']],'Location',[355,527,737,674])

add_block('built-in/S-Function',[sys,'/',['Sampled read with',13,'synchronized pulse1/Message source']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Message source']],...
		'BackGround',5,...
		'function name','trigwksp',...
		'parameters','var,thd,cyclFlag,ini',...
		'Mask Display','Triggered\nread')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Message source']],...
		'Mask Type','Read from workspace')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Message source']],...
		'Mask Dialogue','The raising edge of input pulse trigger the block output the next row from the workspace variable.|Read the variable:|Threshold for the input pulse:|Cyclic read variable (1) or amend zeros (0).|Output before first trigger:')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Message source']],...
		'Mask Translate','var=@1;thd=@2;cyclFlag=@3;ini=@4;')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Message source']],...
		'Mask Help','This block reads the data from a workspace variable. The output is refreshed at the raising edge of the input pulse.')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Message source']],...
		'Mask Entries','var\/.1\/cyc\/ini\/',...
		'position',[180,53,255,97])

add_block('built-in/Outport',[sys,'/',['Sampled read with',13,'synchronized pulse1/out_2']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/out_2']],...
		'Port','2',...
		'position',[195,115,215,135])

add_block('built-in/Outport',[sys,'/',['Sampled read with',13,'synchronized pulse1/out_1']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/out_1']],...
		'position',[295,65,315,85])


%     Subsystem  ['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1'].

new_system([sys,'/',['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1']],'Location',[55,192,283,286])

add_block('built-in/Outport',[sys,'/',['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1/Outport']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1/Outport']],...
		'position',[160,35,180,55])

add_block('built-in/S-Function',[sys,'/',['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1/S-function1']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1/S-function1']],...
		'function name','homopuls',...
		'parameters','samp_time, out_divid, offset',...
		'position',[40,31,105,59])
add_line([sys,'/',['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1']],[110,45;155,45])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1']],...
		'Mask Display','Vector\nPulse',...
		'Mask Type','Pulse generator')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1']],...
		'Mask Dialogue','Vector pulses with sample rate of each pulse as Sample_time ./Divider. |Sample time (scalar, sec):|Divider (integer vector):|Offset (have same dimension as Divider:')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1']],...
		'Mask Translate','samp_time=@1;out_divid=@2;offset=@3;')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1']],...
		'Mask Help','This block generator a vector pulses. The output length is the same as the vector defined in "Divider". The ith element of the output has the sample time Sample_time/Divider(i). All elements in "Divider" must be integers.')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1']],...
		'Mask Entries','ts\/1\/off\/')


%     Finished composite block ['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1'].

set_param([sys,'/',['Sampled read with',13,'synchronized pulse1/Pulses deivide',13,'same sample time1']],...
		'position',[50,56,110,94])
add_line([sys,'/',['Sampled read with',13,'synchronized pulse1']],[115,75;175,75])
add_line([sys,'/',['Sampled read with',13,'synchronized pulse1']],[135,75;135,125;190,125])
add_line([sys,'/',['Sampled read with',13,'synchronized pulse1']],[260,75;290,75])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1']],...
		'Mask Display','plot(0,0,100,100,x,y,v,w);Rd wksp',...
		'Mask Type','Read from workspace')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1']],...
		'Mask Dialogue','Read from a workspace variable at sample time.|Variable (column_number=block_output_length):|Data output sample time (sec):|Repeat flag (1: repeat read, 0: output zeros after eof).|Initial output:')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1']],...
		'Mask Translate','var=@1;td=@2;ts=td(1);if (length(td)>=2),off=td(2);else off=0;end;cyc=@3;ini=@4;[x,y]=srcsicon(7);[v,w]=trigicon(1,75,get_param(gcb,''orientation''),2);')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1']],...
		'Mask Help','This block reads from a workspace variable at a given sample time. The column number is the block output vector length. When the simulation reaches the end of the variable (eof), the block will cyclically output from the first row of the variable or output zeros based on the repeat flag entree. The second output is the synchronization pulse, which outputs a spike when the data is refreshed.')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse1']],...
		'Mask Entries','0\/.1\/1\/0\/')


%     Finished composite block ['Sampled read with',13,'synchronized pulse1'].

set_param([sys,'/',['Sampled read with',13,'synchronized pulse1']],...
		'hide name',0,...
		'position',[245,118,325,162])
add_line(sys,[900,65;925,65])
add_line(sys,[50,85;75,85])
add_line(sys,[435,80;445,80])
add_line(sys,[330,70;345,70])
add_line(sys,[535,70;555,70])
add_line(sys,[120,85;140,85])
add_line(sys,[800,65;815,65])
add_line(sys,[845,65;860,65])
add_line(sys,[230,70;240,70])
add_line(sys,[645,70;660,70])
add_line(sys,[750,70;770,70])
add_line(sys,[330,150;335,150;345,90])
add_line(sys,[330,150;540,150;540,90;555,90])
add_line(sys,[730,20;755,20;755,60;770,60])

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