Communications Blockset | ![]() ![]() |
Quantizing a Signal
This section shows how the Sampled Quantizer Encode, Enabled Quantizer Encode, and Quantizer Decode blocks use the partition and codebook parameters. (The Enabled Quantizer Encode block does not appear in an example, but its behavior is similar to that of the Sampled Quantizer Encode block.) The examples here are analogous to Scalar Quantization Example 1 and Scalar Quantization Example 2 in the Communications Toolbox documentation.
The figure below shows how the Sampled Quantizer Encode block uses the partition and codebook as defined above to map a real vector to a new vector whose entries are either -1, 0.5, 2, or 3. In the Scope window, the bottom signal is the quantization of the (original) top signal.
To open the completed model, click here in the MATLAB Help browser. To build the model, gather and configure these blocks:
[-2.4,-1,-.2,0,.2,1,1.2,1.9,2,2.9,3,3.5]'
.
[0, 1, 3]
.
[-1, 0.5, 2, 3]
.
1
.
1
.
2
.
Connect the blocks as shown in the figure. Also, from the model window's Simulation menu, choose Simulation parameters; then in the Simulation Parameters dialog box, set Stop time to 12
. Running the model produces a scope image similar to the one in the figure. (To make the axis ranges and title exactly match those in the figure, right-click each plot area in the scope and select Axes properties.)
This example, shown in the figure below, illustrates the nature of scalar quantization more clearly. It quantizes a sampled sine wave and plots the original (top) and quantized (bottom) signals. The plot contrasts the smooth sine curve with the polygonal curve of the quantized signal. The vertical coordinate of each flat part of the polygonal curve is a value in the Quantization codebook vector.
To open the completed model, click here in the MATLAB Help browser. To build the model, gather and configure these blocks:
[-1:.2:1]
.
[-1.2:.2:1]
.
1
.
2
.
Connect the blocks as shown in the figure. Also, from the model window's Simulation menu, choose Simulation parameters; then in the Simulation Parameters dialog box, set Stop time to 2*pi
. Running the model produces the scope image as shown in the figure. (To make the axis ranges and title exactly match those in the figure, right-click each plot area in the scope and select Axes properties.)
Determining Which Interval Each Input Is in
The Sampled Quantizer Encode block also returns a signal, at the first output port, that tells which interval each input is in. For example, the model below shows 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.
To open the completed model, click here in the MATLAB Help browser. To build the model, gather and configure these blocks:
[2, 9, 8]
.
[3, 4, 5, 6, 7, 8, 9]
.
3
.
Connect the blocks as shown above. Also, from the model window's Simulation menu, choose Simulation parameters; then in the Simulation Parameters dialog box, set Stop time to 10
. Running the model produces the display numbers as shown in the figure.
You can continue this example by branching the first output of the Sampled Quantizer Encode block, connecting one branch to the input port of the Quantizer Decode block, and connecting the output of the Quantizer Decode block to another Display block. If the two source coding blocks' Quantization codebook parameters match, then the output of the Quantizer Decode block will be the same as the second output of the Sampled Quantizer Encode block. Thus the Quantizer Decode block partially duplicates the functionality of the Sampled Quantizer Encode block, but requires different input data and fewer parameters.
![]() | Representing Quantization Parameters | Implementing Differential Pulse Code Modulation | ![]() |