| Communications Toolbox | ![]() |
This example is similar to the one in the last section. However, whereas the last example created predictor, partition, and codebook in a straightforward but haphazard way, this example uses the same codebook (now called initcodebook) as an initial guess for a new optimized codebook parameter. This example also uses the predictive order, 1, as the desired order of the new optimized predictor. The dpcmopt function creates these optimized parameters, using the sawtooth signal x as training data. The example goes on to quantize the training data itself; in theory, the optimized parameters are suitable for quantizing other data that is similar to x. Notice that the mean square distortion here is much less than the distortion in the previous example.
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
The output is
distor =
0.0063
| Optimizing DPCM Parameters | Companding a Signal | ![]() |
© 1994-2005 The MathWorks, Inc.