## u -Law and Inverse u-Law

The functions u-law and Inverse u law used to perform u-law compression and expansion

```
function [Cx,Xmax] = mulaw(x,mu)
//Non-linear Quantization
//mulaw: mulaw nonlinear quantization
//x = input vector
//Cx = mulaw compressor output
//Xmax = maximum of input vector x
Xmax = max(abs(x));
if(log(1+mu)~=0)
Cx = (log(1+mu*abs(x/Xmax))./log(1+mu));
else
Cx = x/Xmax;
end
Cx = Cx/Xmax; //normalization of output vector
endfunction
////////////////////////////////////////////////////
function x = invmulaw(y,mu)
//Non-linear Quantization
//invmulaw: inverse mulaw nonlinear quantization
//x = output vector
//y = input vector (using mulaw nonlinear comression)
x = (((1+mu).^(abs(y))-1)./mu)
endfunction
```

## Comments:

There are no comments yet!