Note: This page has been translated by MathWorks. Please click here

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

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

`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`

`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,'`

is
the same as the syntax above.** mu/compressor**')

`out = compand(in,Mu,v,'`

implements
a µ-law expander for the input vector ** mu/expander**')

`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,'`

implements
an A-law compressor for the input vector ** A/compressor**')

`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,'`

implements
an A-law expander for the input vector ** A/expander**')

`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`

.The prevailing parameters used in practice are µ= 255 and A = 87.6.

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

$$y=\frac{V\mathrm{log}(1+\mu \left|x\right|/V)}{\mathrm{log}(1+\mu )}\mathrm{sgn}(x)$$

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

$$y=\{\begin{array}{cc}\begin{array}{c}\frac{A\left|x\right|}{1+\mathrm{log}A}\mathrm{sgn}(x)\\ \frac{V(1+\mathrm{log}(A\left|x\right|/V))}{1+\mathrm{log}A}\mathrm{sgn}(x)\end{array}& \begin{array}{c}\text{for}0\le \left|x\right|\le \frac{V}{A}\\ \text{for}\frac{V}{A}\left|x\right|\le V\end{array}\end{array}$$

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

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

Was this topic helpful?