Communications Blockset | ![]() ![]() |
Companding a Signal
In certain applications, such as speech processing, it is common to use a logarithm computation, called a compressor, before quantizing. The inverse operation of a compressor is called an expander. The combination of a compressor and expander is called a compander.
This blockset supports two kinds of companders: µ-law and A-law companders. The reference pages for the A-Law Compressor, A-Law Expander, Mu-Law Compressor, and Mu-Law Expander blocks list the relevant expander and compressor laws.
Example: Using a µ-Law Compander
This example quantizes an exponential signal in two ways and compares the resulting mean square distortions. To create the signal in the MATLAB workspace, execute these commands:
Now, the model in the following figure performs two computations. One computation uses the Sampled Quantizer Encode block with a partition consisting of length-one intervals. The second computation uses the Mu-Law Compressor block to implement a µ-law compressor, the Sampled Quantizer Encode block to quantize the compressed data and, finally, the Mu-Law Expander block to expand the quantized data.
To open the completed model, click here in the MATLAB Help browser. To build the model, gather and configure these blocks:
sig
.
1
.
ceil
(max(sig)).
nocompander
and withcompander
, respectively, in the two copies of this block.
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 80
. Run the model, then execute these commands:
distor = sum((nocompander-sig).^2)/length(sig); distor2 = sum((withcompander-sig).^2)/length(sig); [distor distor2] ans = 0.5348 0.0397
This output shows that the distortion is smaller for the second scheme. This is because equal-length intervals are well suited to the logarithm of the data but not as well suited to the data itself.
![]() | Implementing Differential Pulse Code Modulation | Selected Bibliography for Source Coding | ![]() |