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

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

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

Quantize and encode floating-point inputs to integer outputs

`y = uencode(u,n)`

y = uencode(u,n,v)

y = uencode(u,n,v,* 'SignFlag'*)

`y = uencode(u,n)`

quantizes the entries in
a multidimensional array of floating-point numbers `u`

and
encodes them as integers using 2^{n}-level
quantization. `n`

must
be an integer between 2 and 32 (inclusive). Inputs can be real or
complex, double- or single-precision. The output y and the input `u`

are
arrays of the same size. The elements of the output y are unsigned
integers with magnitudes in the range [0, 2^{n}-1].
Elements of the input `u`

outside of the range `[-1,1]`

are
treated as overflows and are saturated.

For entries in the input

`u`

that are less than -1, the value of the output of`uencode`

is 0.For entries in the input

`u`

that are greater than 1, the value of the output of`uencode`

is 2^{n}-1.

`y = uencode(u,n,v)`

allows
the input `u`

to have entries with floating-point
values in the range `[-v,v]`

before saturating them
(the default value for `v`

is 1).
Elements of the input `u`

outside of the range `[-v,v]`

are
treated as overflows and are saturated:

For input entries less than -

`v`

, the value of the output of`uencode`

is 0.For input entries greater than

`v`

, the value of the output of`uencode`

is 2^{n}– 1.

`y = uencode(u,n,v,`

maps
entries in a multidimensional array of floating-point numbers * 'SignFlag'*)

`u`

whose
entries have values in the range [`-v,v`

] to an integer
output `y`

. Input entries outside this range are
saturated. The integer type of the output depends on the number of
quantization levels 2`'SignFlag'`

`'signed'`

: Outputs are signed integers with magnitudes in the range [-2^{n}/2, (2^{n}/2) – 1].`'unsigned'`

(default): Outputs are unsigned integers with magnitudes in the range [0, 2^{n}– 1].

The output data types are optimized for the number of bits as shown in the table below.

`uencode`

maps the floating-point input value
to an integer value determined by the requirement for 2^{n} levels
of quantization. This encoding adheres to the definition for uniform
encoding specified in ITU-T Recommendation G.701. The input range `[-v,v]`

is
divided into 2^{n} evenly spaced intervals.
Input entries in the range `[-v,v]`

are first quantized
according to this subdivision of the input range, and then mapped
to one of 2^{n} integers. The range of the
output depends on whether or not you specify that you want signed
integers.

[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.

Was this topic helpful?