# udecode

Decode 2n-level quantized integer inputs to floating-point outputs

## Syntax

``x = udecode(y,n)``
``x = udecode(y,n,v)``
``x = udecode(y,n,v,OFM)``

## Description

````x = udecode(y,n)` performs the inverse operation of `uencode` by reconstructing floating-point values from an array of 2`n`-level quantized integers `y`. The `udecode` function returns a floating-point output array `x` with values within the range from `-1` to `1`.```

example

````x = udecode(y,n,v)` returns a floating-point output array with values within the range from `-v` to `v`.```

example

````x = udecode(y,n,v,OFM)` also specifies a method to treat overflows in the quantized integer input `y`.```

example

## Examples

collapse all

Create a vector of 8-bit signed integers. Decode with three bits.

```u = int8([-1 1 2 -5]); ysat = udecode(u,3)```
```ysat = 1×4 -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×4 -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×4 -1.5000 1.5000 3.0000 4.5000 ```

`yprec = udecode(u,5)`
```yprec = 1×4 -0.0625 0.0625 0.1250 -0.3125 ```

## Input Arguments

collapse all

Quantized integer inputs, specified as a vector, matrix, or multidimensional array.

• Signed inputs — Specify `int8`, `int16` or `int32` values.

• Unsigned inputs — Specify `uint8`, `uint16` or `uint32` values.

The `udecode` function decodes the real and imaginary components of complex-valued inputs `y` independently.

Example: `y = int16([-6 9 23 1 10 -7])`

Data Types: `int8` | `int16` | `int32` | `uint8` | `uint16` | `uint32`
Complex Number Support: Yes

Measure of number of quantization levels, specified as a positive integer scalar between 2 and 32, inclusive. The value of 2`n` indicates the number of quantization levels established for the quantized array `y`, and defines a quantization range for `y`.

The quantization range depends on the value of `n` and the sign nature of `y`:

• Signed inputs — From –2`n`/2 to (2`n`/2) – 1.

• Unsigned inputs — From 0 to (2`n` – 1).

The `udecode` function considers any value from `y` outside the quantization range as an overflow.

Data Types: `double`

Unsaturation amplitude, specified as a positive scalar. The ```udecode ```decodes `y` such that the output `x` has values in the range `[-v,v]`, preventing signal saturation in the floating-point output.

Data Types: `double`

Method to treat overflows, specified as:

• `"saturate"` — Saturate overflows. The `udecode` function treats overflowing elements in `y` by reassigning their values equal to the closest endpoint of the quantization range.

• Signed inputs — `udecode` sets overflowing elements to `-2^n/2` (overflow below quantization range) or `2^n/2-1` (overflow above quantization range).

• Unsigned inputs — `udecode` sets overflowing elements to `2^n-1` (overflow above quantization range).

• `"wrap"` — Wrap all overflows. The `udecode` treats overflowing entries in `y` by using the modulo 2n operation to reassign their values.

• Signed inputs — `udecode` sets overflowing elements `yOF` to `mod(yOF+2^n/2,2^n)-(2^n/2)`.

• Unsigned inputs — `udecode` sets overflowing elements `yOF` to `mod(yOF,2^n)`.

Data Types: `char` | `string`

## Output Arguments

collapse all

Unencoded floating-point outputs, returned as a vector, matrix, or multidimensional array. The output array `x` has the same dimension as `y`.

## Algorithms

The algorithm adheres to the definition for uniform decoding specified in ITU-T Recommendation G.701. Integer input values are uniquely mapped (decoded) from one of uniformly spaced integer values to quantized floating-point values in the range `[-v,v]`. The smallest integer input value allowed is mapped to `-v` and the largest integer input value allowed is mapped to `v`. Values outside of the input range are either saturated or wrapped, according to specification.

## References

[1] International Telecommunication Union. General Aspects of Digital Transmission Systems: Vocabulary of Digital Transmission and Multiplexing, and Pulse Code Modulation (PCM) Terms. ITU-T Recommendation G.701. March, 1993.

## Version History

Introduced before R2006a

expand all