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.ScalarQuantizerDecoder System object

Convert each index value into quantized output value


The ScalarQuantizerDecoder object converts each index value into a quantized output value. The specified codebook defines the set of all possible quantized output values or codewords. Input index values less than 0 are set to 0 and index values greater N – 1 are set to N – 1. N is the length of the codebook vector.

To convert an index value into a quantized output value:

  1. Define and set up your scalar quantizer decoder. See Construction.

  2. Call step to convert the index value according to the properties of dsp.ScalarQuantizerDecoder. 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.


sqdec = dsp.ScalarQuantizerDecoder returns a scalar quantizer decoder System object, sqdec, that transforms zero-based input index values into quantized output values.

sqdec = dsp.ScalarQuantizerDecoder('PropertyName',PropertyValue,...) returns a scalar quantizer decoder object, sqdec, with each specified property set to the specified value.



How to specify codebook values

Specify how to determine the codebook values as Property or Input port. The default is Property.



Specify the codebook as a vector of quantized output values that correspond to each index value. The default is 1:10. This property is tunable.


Data type of codebook and quantized output

Specify the data type of the codebook and quantized output values as Same as input, double, single or Custom. The default is double.

 Fixed-Point Properties


stepDecode using scalar quantization
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).

Given a codebook and index values as inputs, determine the corresponding output quantized values.

codebook = single([-2.1655 -1.3238 -0.7365 -0.2249 0.2726, ...
    0.7844 1.3610 2.1599]);
indices = uint8([1 3 5 7 6 4 2 0]);
sqdec = dsp.ScalarQuantizerDecoder;
sqdec.CodebookSource = 'Input port';
qout = sqdec(indices, codebook);


This object implements the algorithm, inputs, and outputs described on the Scalar Quantizer Decoder block reference page. The object properties correspond to the block parameters, except:

There is no object property that directly corresponds to the Action for out of range index value block parameter. The object sets any index values less than 0 to 0 and any index values greater than or equal to N to N – 1.

Extended Capabilities

Introduced in R2012a