Example code in Differential Pulse Code Modulation
2 views (last 30 days)
Show older comments
Output of an example code in Differential Pulse Code Modulation in https://www.mathworks.com/help/comm/ug/differential-pulse-code-modulation.html is different from local calculation.
t = [0:pi/50:2*pi];
x = sawtooth(3*t); % Original signal
initcodebook = [-1:.1:1]; % Initial guess at codebook
% Optimize parameters, using initial codebook and order 1.
[predictor,codebook,partition] = dpcmopt(x,1,initcodebook);
% Quantize x using DPCM.
encodedx = dpcmenco(x,codebook,partition,predictor);
% Try to recover x from the modulated signal.
decodedx = dpcmdeco(encodedx,codebook,predictor);
distor = sum((x-decodedx).^2)/length(x) % Mean square error
Example output on the wab page is 0.0063, but locally executed answer is 8.6801e-04. "codebook" seems strange in the last value (0.4791, that is smaller than the previous value 0.7008) as below. Is this a bug or something else ?
codebook =
-1.7571 -1.2431 -0.8946 -0.7118 -0.6000 -0.5000 -0.3999 -0.2987 -0.1945 -0.0867
0.0048 0.0981 0.1915 0.2963 0.3991 0.4998 0.5882 0.6283 0.6543 0.7008
0.4791
0 Comments
Answers (0)
See Also
Categories
Find more on Communications Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!