| Communications Toolbox | ![]() |
The quantiz function also returns a vector that tells which interval each input is in. For example, the output below says that the input entries lie within the intervals labeled 0, 6, and 5, respectively. Here, the 0th interval consists of real numbers less than or equal to 3; the 6th interval consists of real numbers greater than 8 but less than or equal to 9; and the 5th interval consists of real numbers greater than 7 but less than or equal to 8.
partition = [3,4,5,6,7,8,9]; index = quantiz([2 9 8],partition)
The output is
index =
0
6
5
If you continue this example by defining a codebook vector such as
codebook = [3,3,4,5,6,7,8,9];
then the equation below relates the vector index to the quantized signal quants.
quants = codebook(index+1);
This formula for quants is exactly what the quantiz function uses if you instead phrase the example more concisely as below.
partition = [3,4,5,6,7,8,9]; codebook = [3,3,4,5,6,7,8,9]; [index,quants] = quantiz([2 9 8],partition,codebook);
| Scalar Quantization Example 2 | Optimizing Quantization Parameters | ![]() |
© 1994-2005 The MathWorks, Inc.