| Communications Toolbox | ![]() |
The code below shows how the quantiz function uses partition and codebook to map a real vector, samp, to a new vector, quantized, whose entries are either -1, 0.5, 2, or 3.
partition = [0,1,3]; codebook = [-1, 0.5, 2, 3]; samp = [-2.4, -1, -.2, 0, .2, 1, 1.2, 1.9, 2, 2.9, 3, 3.5, 5]; [index,quantized] = quantiz(samp,partition,codebook); quantized
The output is below.
quantized =
Columns 1 through 6
-1.0000 -1.0000 -1.0000 -1.0000 0.5000 0.5000
Columns 7 through 12
2.0000 2.0000 2.0000 2.0000 2.0000 3.0000
Column 13
3.0000
| Representing Codebooks | Scalar Quantization Example 2 | ![]() |
© 1994-2005 The MathWorks, Inc.