This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

dsp.UniformEncoder System object

Quantize and encode floating-point input into integer output


The UniformEncoder object quantizes floating-point input, using the precision you specify in the NumBits property, and encodes the quantized input into integer output. The operations of the uniform encoder adhere to the definition for uniform encoding specified in ITU-T Recommendation G.701.

To quantize and encode a floating-point input into an integer output:

  1. Define and set up your uniform encoder. See Construction.

  2. Call step to encode the input according to the properties of dsp.UniformEncoder. The behavior of step is specific to each object in the toolbox.


Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


ue = dsp.UniformEncoder returns a uniform encoder, ue, that quantizes floating-point input samples and encodes them as integers using 2N-level quantization, where N is an integer.

ue = dsp.UniformEncoder('PropertyName',PropertyValue,...) returns an uniform encoder, ue, with each specified property set to the specified value.

ue = dsp.UniformEncoder(peakvalue,numbits,
returns a uniform encoder, ue, with the PeakValue property set to peakvalue, the NumBits property set to numbits, and other specified properties set to the specified values.



Largest input amplitude to be encoded

Specify the largest input amplitude to be encoded, as a nonnegative numeric scalar. If the real or imaginary input are outside of the interval [–P,(1 – 2(1 – B))P], where P is the peak value and B is the value of the NumBits property, the uniform encoder saturates (independently for complex inputs) at those limits. The default is 1.


Number of bits needed to represent output

Specify the number of bits needed to represent the integer output as an integer value between 2 and 32. The number of levels at which the uniform encoder quantizes the floating-point input is 2B, where B is the number of bits. The default is 8.


Data type of output

Specify the data type of the output as Unsigned integer or Signed integer. Unsigned outputs are uint8, uint16, or uint32, and signed outputs are int8, int16, or int32. The quantized inputs are linearly (uniformly) mapped to the intermediate integers in the interval [0,2(B – 1)] when you set this property to Unsigned integer, and in the interval [–2(B – 1),2(B – 1) – 1] when you set this property to Signed integer. The variable B in both expressions corresponds to the value of the NumBits property.


stepQuantize and encode input
Common to All System Objects

Allow System object property value changes


expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

ue = dsp.UniformEncoder;
ue.PeakValue = 2;
ue.NumBits = 4;
ue.OutputDataType = 'Signed integer';
x = (-1:0.01:1)'; % Create an input sequence
x_encoded = ue(x);
plot(x, x_encoded,'.');
xlabel('Input'); ylabel('Encoded Output'); grid


This object implements the algorithm, inputs, and outputs described on the Uniform Encoder block reference page. The object properties correspond to the block parameters.

Introduced in R2012a