You are here : matlabSignal Processingudecode

udecode() - Signal Processing

```y = udecode(u,n) inverts
the operation of uencode and
reconstructs quantized floating-point values from an encoded multidimensional
array of integers u. The input argument n must
be an integer between 2 and 32. The integer n specifies
that there are 2n quantization levels for
the inputs, so that entries in u must be either:Signed integers in the range [-2n/2, (2n/2) – 1]Unsigned integers in the range [0, 2n – 1]Inputs can be real or complex values of any integer data type
(uint8, uint16, uint32, int8, int16, int32). Overflows (entries in u outside
of the ranges specified above) are saturated to the endpoints of the
range interval. The output y has the same dimensions
as u. Its entries have values in the range [-1,1]. y = udecode(u,n,v) decodes u such
that the output y has values in the range [-v,v],
where the default value for v is 1.y = udecode(u,n,v,'SaturateMode') decodes u and
treats input overflows (entries in u outside of [-v,v])
according to the string 'saturatemode',
which can be one of the following: 'saturate': Saturate overflows.
This is the default method for treating overflows.Entries in signed inputs u whose
values are outside of the range [-2n/2, (2n/2) – 1] are assigned the value determined by the closest endpoint
of this interval. Entries in unsigned inputs u whose
values are outside of the range [0, 2n-1]
are assigned the value determined by the closest endpoint of this
interval. 'wrap': Wrap all overflows according
to the following:Entries in signed inputs u whose
values are outside of the range [-2n/2, (2n/2) – 1] are wrapped back into that range using modulo 2n arithmetic
(calculated using u = mod(u+2^n/2,2^n)-(2^n/2)).Entries in unsigned inputs u whose
values are outside of the range [0, 2n – 1] are wrapped back into the
required range before decoding using modulo 2n arithmetic
(calculated using u = mod(u,2^n)).```

Syntax

`y = udecode(u,n)y = udecode(u,n,v)y = udecode(u,n,v,'SaturateMode')`

Example

```Use udecode to Decode IntegersOpen This Example
Create a signed eight-bit integer string. Decode with three bits.
u = int8([-1 1 2 -5]);
ysat = udecode(u,3)

ysat =

-0.2500    0.2500    0.5000   -1.0000

Notice the last entry in u saturates to 1, the default peak input magnitude. Change the peak input magnitude to 6.ysatv = udecode(u,3,6)

ysatv =

-1.5000    1.5000    3.0000   -6.0000

The last input entry still saturates. Wrap the overflows.ywrap = udecode(u,3,6,'wrap')

ywrap =

-1.5000    1.5000    3.0000    4.5000

Add more quantization levels.yprec = udecode(u,5)

yprec =

-0.0625    0.0625    0.1250   -0.3125```