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

📄 tstdpcms.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 2 页
字号:
set_param([sys,'/',['DPCM',13,'decode']],...
		'Mask Translate','num=@1;den=@2;codebook=@3;sample_time=@4;')
set_param([sys,'/',['DPCM',13,'decode']],...
		'Mask Help','This block recovers the source code using the DPCM decode method. The parameters in this block should match the parameters in the DPCM encoder.')
set_param([sys,'/',['DPCM',13,'decode']],...
		'Mask Entries','p_trans\/1\/codebook\/.1\/')


%     Finished composite block ['DPCM',13,'decode'].

set_param([sys,'/',['DPCM',13,'decode']],...
		'hide name',0,...
		'position',[265,43,345,87])


%     Subsystem  ['DPCM',13,'encode'].

new_system([sys,'/',['DPCM',13,'encode']])
set_param([sys,'/',['DPCM',13,'encode']],'Location',[469,413,916,648])


%     Subsystem  ['DPCM',13,'encode/Sampled',13,'quantizer enco'].

new_system([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']])
set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],'Location',[37,120,369,253])

add_block('built-in/Outport',[sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco/out_3']])
set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco/out_3']],...
		'Port','3',...
		'position',[255,85,275,105])

add_block('built-in/Outport',[sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco/out_2']])
set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco/out_2']],...
		'Port','2',...
		'position',[290,55,310,75])

add_block('built-in/Outport',[sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco/out_1']])
set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco/out_1']],...
		'position',[260,20,280,40])

add_block('built-in/Inport',[sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco/in_1']])
set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco/in_1']],...
		'position',[15,55,35,75])

add_block('built-in/Demux',[sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco/Demux']])
set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco/Demux']],...
		'outputs','[n n n]',...
		'position',[175,47,215,83])

add_block('built-in/S-Function',[sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco/S-function']])
set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco/S-function']],...
		'function name','simquans',...
		'parameters','n, partition, codebook,sample_time',...
		'position',[80,55,135,75])
add_line([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],[220,75;235,75;235,95;250,95])
add_line([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],[220,65;285,65])
add_line([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],[220,55;235,55;235,30;255,30])
add_line([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],[140,65;170,65])
add_line([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],[40,65;75,65])
set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],...
		'Mask Display','Scalar\nquantizer',...
		'Mask Type','Scalar quantization encode')
set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],...
		'Mask Dialogue','Quantize an analog signal to finite digital\nindex (1st outport), quantization value (2nd outport), and distortion (3rd outport) at every sample time point.|Quantization partition:|Quantization codebook:|Input signal vector length:|Sample time (sec):')
set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],...
		'Mask Translate','partition=@1;codebook=@2;n=@3;sample_time=@4;')
set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],...
		'Mask Help','This block quantizes the input signal to quantization index (1st outport), quantized value (2nd outport), and distortion (3rd outport) at every sample point. The inptu signa can be a vector. When the sample time is a two elements vector, the second element is the offset value. The length of partition is one less than the length of codebook. Use LLOYDS to optimize the partition and codebook.')
set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],...
		'Mask Entries','partition\/codebook\/1\/sample_time\/')


%     Finished composite block ['DPCM',13,'encode/Sampled',13,'quantizer enco'].

set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],...
		'position',[155,43,220,87])

add_block('built-in/Filter',[sys,'/',['DPCM',13,'encode/Filter']])
set_param([sys,'/',['DPCM',13,'encode/Filter']],...
		'orientation',2,...
		'Numerator','num',...
		'Denominator','den',...
		'Sample time','sample_time',...
		'position',[150,120,210,160])

add_block('built-in/Outport',[sys,'/',['DPCM',13,'encode/out_2']])
set_param([sys,'/',['DPCM',13,'encode/out_2']],...
		'Port','2',...
		'position',[295,55,315,75])

add_block('built-in/Outport',[sys,'/',['DPCM',13,'encode/out_1']])
set_param([sys,'/',['DPCM',13,'encode/out_1']],...
		'position',[295,10,315,30])

add_block('built-in/Sum',[sys,'/',['DPCM',13,'encode/Sum1']])
set_param([sys,'/',['DPCM',13,'encode/Sum1']],...
		'position',[265,100,285,120])

add_block('built-in/Sum',[sys,'/',['DPCM',13,'encode/Sum']])
set_param([sys,'/',['DPCM',13,'encode/Sum']],...
		'inputs','+-',...
		'position',[105,55,125,75])

add_block('built-in/Inport',[sys,'/',['DPCM',13,'encode/in_1']])
set_param([sys,'/',['DPCM',13,'encode/in_1']],...
		'position',[40,50,60,70])
add_line([sys,'/',['DPCM',13,'encode']],[225,65;250,65;260,105])
add_line([sys,'/',['DPCM',13,'encode']],[250,65;290,65])
add_line([sys,'/',['DPCM',13,'encode']],[225,50;250,50;250,20;290,20])
add_line([sys,'/',['DPCM',13,'encode']],[145,140;80,140;80,70;100,70])
add_line([sys,'/',['DPCM',13,'encode']],[80,115;260,115])
add_line([sys,'/',['DPCM',13,'encode']],[290,110;300,110;300,140;215,140])
add_line([sys,'/',['DPCM',13,'encode']],[130,65;150,65])
add_line([sys,'/',['DPCM',13,'encode']],[65,60;100,60])
set_param([sys,'/',['DPCM',13,'encode']],...
		'Mask Display','DPCM\nencode',...
		'Mask Type','DPCM encode')
set_param([sys,'/',['DPCM',13,'encode']],...
		'Mask Dialogue','Output the DPCM encoded index to the\n1st outport and the quantization\nrecovered value to the 2nd outport.|Predictor numerator:|Predictor denominator:|Quantization partition:|Quantization codebook:|Sample time (sec):')
set_param([sys,'/',['DPCM',13,'encode']],...
		'Mask Translate','num=@1;den=@2;partition=@3;codebook=@4;sample_time=@5;')
set_param([sys,'/',['DPCM',13,'encode']],...
		'Mask Help','The 1st outport outputs the index of the predictive error. The 2nd outport outputs the predictive error. Use the DPCMOPT function for the FIR filter training. A delta modulation is a special case with the numerator as [0,x], the denominator as 1 for the\npredictor.')
set_param([sys,'/',['DPCM',13,'encode']],...
		'Mask Entries','p_trans\/1\/partition\/codebook\/.1\/')


%     Finished composite block ['DPCM',13,'encode'].

set_param([sys,'/',['DPCM',13,'encode']],...
		'hide name',0,...
		'position',[120,53,200,97])

add_block('built-in/Note',[sys,'/',['The parameters are trained by double clicking "Load Data" block. p_trans is a',13,'1st order FIR filter, codebook is a length 8 vector, partition is a length 7 vector.']])
set_param([sys,'/',['The parameters are trained by double clicking "Load Data" block. p_trans is a',13,'1st order FIR filter, codebook is a length 8 vector, partition is a length 7 vector.']],...
		'position',[265,140,270,145])

add_block('built-in/Note',[sys,'/',['The commands used for the parameter training are as follows. You may train the',13,'parameter if you have changed the signal source.',13,'x=sin([0:.1:40]);[p_trans,codebook,partition]=dpcmopt(x,1,8);']])
set_param([sys,'/',['The commands used for the parameter training are as follows. You may train the',13,'parameter if you have changed the signal source.',13,'x=sin([0:.1:40]);[p_trans,codebook,partition]=dpcmopt(x,1,8);']],...
		'position',[270,175,275,180])


%     Subsystem  ['DPCM data',13,'training'].

new_system([sys,'/',['DPCM data',13,'training']])
set_param([sys,'/',['DPCM data',13,'training']],'Location',[111,168,452,354])
set_param([sys,'/',['DPCM data',13,'training']],...
		'Mask Display','Load\nData',...
		'Mask Dialogue','eval(''x=sin([0:.1:40]);[p_trans,codebook,partition]=dpcmopt(x,1,8);'')')


%     Finished composite block ['DPCM data',13,'training'].

set_param([sys,'/',['DPCM data',13,'training']],...
		'ForeGround',2,...
		'hide name',0,...
		'position',[465,68,525,112])

add_block('built-in/Note',[sys,'/','This example converts the analog signal to a 3-bits digital signal.'])
set_param([sys,'/','This example converts the analog signal to a 3-bits digital signal.'],...
		'position',[225,220,230,225])

add_block('built-in/Note',[sys,'/','This example demonstrates a delta modulation.'])
set_param([sys,'/','This example demonstrates a delta modulation.'],...
		'position',[150,115,155,120])
add_line(sys,[80,30;415,30])
add_line(sys,[105,30;115,75])
add_line(sys,[350,55;365,55;365,45;415,45])
add_line(sys,[205,65;260,65])
add_line(sys,[460,40;485,40])

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