Communications Toolbox    

Quantizing a Signal

The previous section described how you can represent the partition and codebook that determine your scalar quantization process. This section shows how to use these parameters in the quantiz function.

Scalar Quantization Example 1

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.

Scalar Quantization Example 2

This example illustrates the nature of scalar quantization more clearly. After quantizing a sampled sine wave, it plots the original and quantized signals. The plot contrasts the x's that make up the sine curve with the dots that make up the quantized signal. The vertical coordinate of each dot is a value in the vector codebook.

Determining Which Interval Each Input Is In

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.

If you continue this example by defining a codebook vector such as

then the equation below relates the vector index to the quantized signal quants.

This formula for quants is exactly what the quantiz function uses if you instead phrase the example more concisely as below.


  Representing Quantization Parameters Optimizing Quantization Parameters