Main Content


Quantize and encode floating-point input into integer output


The dsp.UniformEncoder System 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. Create the dsp.UniformEncoder object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?.




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(peakvalue,numbits) returns a uniform encoder, ue, with the PeakValue property set to peakvalue and the NumBits property set to numbits.

ue = dsp.UniformEncoder(___,Name,Value) 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.


expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

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.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

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.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

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.





Y = ue(X) quantizes and encodes the input X to output Y.

Input Arguments

expand all

Data input, specified as a vector or a matrix. The input X can be real or complex and double-, or single-precision values.

Data Types: single | double
Complex Number Support: Yes

Output Arguments

expand all

Quantized and encoded output, returned as a vector or a matrix.

The uniform encoder chooses the output data type according to the table.

Number of BitsUnsigned IntegerSigned Integer
2 to 8uint8int8
9 to 16uint16int16
17 to 32uint32int32

The row in the table corresponds to the value of the NumBits property, and the column in the table corresponds to the value of the OutputDataType property.

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

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:


expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object


collapse all

Note: If you are using R2016a or an earlier release, replace each call to the object with the equivalent step syntax. For example, obj(x) becomes step(obj,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,'.')
ylabel('Encoded Output')


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

See Also


Introduced in R2012a