Products & Services Solutions Academia Support User Community Company

Learn more about Communications Toolbox   

compand - Source code mu-law or A-law compressor or expander

Syntax

out = compand(in,param,v)
out = compand(in,Mu,v,'mu/compressor')
out = compand(in,Mu,v,'mu/expander')
out = compand(in,A,v,'A/compressor')
out = compand(in,A,v,'A/expander')

Description

out = compand(in,param,v) implements a µ-law compressor for the input vector in. Mu specifies µ, and v is the input signal's maximum magnitude. out has the same dimensions and maximum magnitude as in.

out = compand(in,Mu,v,'mu/compressor') is the same as the syntax above.

out = compand(in,Mu,v,'mu/expander') implements a µ-law expander for the input vector in. Mu specifies µ and v is the input signal's maximum magnitude. out has the same dimensions and maximum magnitude as in.

out = compand(in,A,v,'A/compressor') implements an A-law compressor for the input vector in. The scalar A is the A-law parameter, and v is the input signal's maximum magnitude. out is a vector of the same length and maximum magnitude as in.

out = compand(in,A,v,'A/expander') implements an A-law expander for the input vector in. The scalar A is the A-law parameter, and v is the input signal's maximum magnitude. out is a vector of the same length and maximum magnitude as in.

Examples

The examples below illustrate the fact that compressors and expanders perform inverse operations.

compressed = compand(1:5,87.6,5,'a/compressor')
expanded = compand(compressed,87.6,5,'a/expander')

The output is

compressed =

    3.5296    4.1629    4.5333    4.7961    5.0000


expanded =

    1.0000    2.0000    3.0000    4.0000    5.0000

Algorithm

For a given signal x, the output of the µ-law compressor is

where V is the maximum value of the signal x, µ is the µ-law parameter of the compander, log is the natural logarithm, and sgn is the signum function (sign in MATLAB).

The output of the A-law compressor is

where A is the A-law parameter of the compander and the other elements are as in the µ-law case.

See Also

quantiz, dpcmenco, dpcmdeco, Companding a Signal

References

[1] Sklar, Bernard, Digital Communications: Fundamentals and Applications, Englewood Cliffs, NJ, Prentice-Hall, 1988.

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS