📄 com_frmt.m
字号:
'Mask Display','Quantizer\ndecode',...
'Mask Type','Scalar quantization decode')
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode']],...
'Mask Dialogue','Output is one of the elements in codebook. Output vector length is the same as the input length.|Quantization codebook:',...
'Mask Translate','codebook=@1;')
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode']],...
'Mask Help','This block takes the quantized index as input and returns the quantization value. The output vector size the the same as the input vector size. Input 0, 1, ..., N-1 leads to CK(1), CK(2), .. CK(N) ouptut.')
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode']],...
'Mask Entries','codebook\/')
% Finished composite block ['DPCM',13,'decode/Quantizer',13,'decode'].
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode']],...
'position',[85,30,145,70])
add_block('built-in/Sum',[sys,'/',['DPCM',13,'decode/Sum1']])
set_param([sys,'/',['DPCM',13,'decode/Sum1']],...
'position',[185,45,205,65])
add_block('built-in/Filter',[sys,'/',['DPCM',13,'decode/Filter']])
set_param([sys,'/',['DPCM',13,'decode/Filter']],...
'orientation',2,...
'Numerator','num',...
'Denominator','den',...
'Sample time','sample_time',...
'position',[200,90,260,130])
add_block('built-in/Outport',[sys,'/',['DPCM',13,'decode/out_1']])
set_param([sys,'/',['DPCM',13,'decode/out_1']],...
'position',[315,45,335,65])
add_block('built-in/Outport',[sys,'/',['DPCM',13,'decode/out_2']])
set_param([sys,'/',['DPCM',13,'decode/out_2']],...
'Port','2',...
'position',[235,10,255,30])
add_line([sys,'/',['DPCM',13,'decode']],[55,50;80,50])
add_line([sys,'/',['DPCM',13,'decode']],[195,110;165,110;165,60;180,60])
add_line([sys,'/',['DPCM',13,'decode']],[210,55;310,55])
add_line([sys,'/',['DPCM',13,'decode']],[285,55;285,110;265,110])
add_line([sys,'/',['DPCM',13,'decode']],[150,50;180,50])
add_line([sys,'/',['DPCM',13,'decode']],[160,50;160,20;230,20])
set_param([sys,'/',['DPCM',13,'decode']],...
'Mask Display','DPCM\ndecode',...
'Mask Type','DPCM decode')
set_param([sys,'/',['DPCM',13,'decode']],...
'Mask Dialogue','Input the DPCM coded index. Output\nDPCM decodes to the 1st outport and\nquantization decode to the 2nd outport.|Predictor transfer function numerator:|Predictor transfer function denominator:|Quantization codebook:|Sample time (sec):')
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','[0 .9963]\/1\/[-.0848 -.029 .0298 .0853]\/.1\/')
% Finished composite block ['DPCM',13,'decode'].
set_param([sys,'/',['DPCM',13,'decode']],...
'position',[165,133,245,177])
% Subsystem ['DPCM',13,'encode'].
new_system([sys,'/',['DPCM',13,'encode']])
set_param([sys,'/',['DPCM',13,'encode']],'Location',[469,413,916,648])
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_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/Sum',[sys,'/',['DPCM',13,'encode/Sum1']])
set_param([sys,'/',['DPCM',13,'encode/Sum1']],...
'position',[265,100,285,120])
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/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/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])
% 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/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_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/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/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/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_3']])
set_param([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco/out_3']],...
'Port','3',...
'position',[255,85,275,105])
add_line([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],[40,65;75,65])
add_line([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],[140,65;170,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']],[220,65;285,65])
add_line([sys,'/',['DPCM',13,'encode/Sampled',13,'quantizer enco']],[220,75;235,75;235,95;250,95])
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_line([sys,'/',['DPCM',13,'encode']],[65,60;100,60])
add_line([sys,'/',['DPCM',13,'encode']],[130,65;150,65])
add_line([sys,'/',['DPCM',13,'encode']],[290,110;300,110;300,140;215,140])
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']],[225,50;250,50;250,20;290,20])
add_line([sys,'/',['DPCM',13,'encode']],[225,65;250,65;260,105])
add_line([sys,'/',['DPCM',13,'encode']],[250,65;290,65])
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','[0 .9963]\/1\/[-.0569 .0004 .0576]\/[-.0848 -.029 .0298 .0853]\/.1\/')
% Finished composite block ['DPCM',13,'encode'].
set_param([sys,'/',['DPCM',13,'encode']],...
'position',[35,133,115,177])
% Subsystem ['Triggered',13,'quantizer demo'].
new_system([sys,'/',['Triggered',13,'quantizer demo']])
set_param([sys,'/',['Triggered',13,'quantizer demo']],'Location',[811,642,1004,748])
set_param([sys,'/',['Triggered',13,'quantizer demo']],...
'Mask Display','Triggered\nquantizer\ndemo',...
'Mask Dialogue','eval(''tstquant;'')')
% Finished composite block ['Triggered',13,'quantizer demo'].
set_param([sys,'/',['Triggered',13,'quantizer demo']],...
'orientation',2,...
'BackGround',7,...
'position',[295,358,375,402])
% Subsystem ['Quantizer',13,'decode'].
new_system([sys,'/',['Quantizer',13,'decode']])
set_param([sys,'/',['Quantizer',13,'decode']],'Location',[596,274,888,411])
add_block('built-in/S-Function',[sys,'/',['Quantizer',13,'decode/Index lookup',13,'table']])
set_param([sys,'/',['Quantizer',13,'decode/Index lookup',13,'table']],...
'function name','indxtabl',...
'parameters','codebook',...
'Mask Display','Index\nLookup tb',...
'Mask Type','No-intepret Lookup table')
set_param([sys,'/',['Quantizer',13,'decode/Index lookup',13,'table']],...
'Mask Dialogue','Output one of the values in the look-up table.|Codebook:',...
'Mask Translate','codebook=@1;')
set_param([sys,'/',['Quantizer',13,'decode/Index lookup',13,'table']],...
'Mask Help','When codebook is a matrix, the block input can only be a scalar. The block output the row with the column index provided in the input. When codebook is a vector, the block output the same length as the input vector. The output is one of the values in codebook with the index provided by the input.')
set_param([sys,'/',['Quantizer',13,'decode/Index lookup',13,'table']],...
'Mask Entries','codebook\/',...
'position',[105,19,165,61])
add_block('built-in/Outport',[sys,'/',['Quantizer',13,'decode/out_1']])
set_param([sys,'/',['Quantizer',13,'decode/out_1']],...
'position',[225,30,245,50])
add_block('built-in/Inport',[sys,'/',['Quantizer',13,'decode/in_1']])
set_param([sys,'/',['Quantizer',13,'decode/in_1']],...
'position',[20,30,40,50])
add_line([sys,'/',['Quantizer',13,'decode']],[45,40;100,40])
add_line([sys,'/',['Quantizer',13,'decode']],[170,40;220,40])
set_param([sys,'/',['Quantizer',13,'decode']],...
'Mask Display','Quantizer\ndecode',...
'Mask Type','Scalar quantization decode')
set_param([sys,'/',['Quantizer',13,'decode']],...
'Mask Dialogue','Output the value in the given codebook\nbased on the input index value.|Quantization codebook:',...
'Mask Translate','codebook=@1;')
set_param([sys,'/',['Quantizer',13,'decode']],...
'Mask Help','This block takes the quantized index as input and outputs the quantization value. The output vector size is the same as the input vector size. Inputs 0, 1, ..., N-1 lead to CK(1), CK(2), .. CK(N) output.')
set_param([sys,'/',['Quantizer',13,'decode']],...
'Mask Entries','[-.825 -.5 0, .5 .825]\/')
% Finished composite block ['Quantizer',13,'decode'].
set_param([sys,'/',['Quantizer',13,'decode']],...
'position',[165,58,245,102])
add_line(sys,[120,65;140,65;140,80;160,80])
add_line(sys,[120,145;140,145;140,155;160,155])
add_line(sys,[120,230;160,230])
add_line(sys,[120,305;160,305])
add_line(sys,[120,365;125,365;125,380;165,380])
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 + -