Package: dsp
Associate input value with index value of quantization region
The ScalarQuantizerEncoder
object encodes
each input value by associating that value with the index value of
the quantization region. Then, the object outputs the index of the
associated region.
To encode an input value by associating it with an index value of the quantization region:
Define and set up your scalar quantizer encoder. See Construction.
Call step
to encode the input value
according to the properties of dsp.ScalarQuantizerEncoder
.
The behavior of step
is specific to each object in
the toolbox.
H = dsp.ScalarQuantizerEncoder
returns
a scalar quantizer encoder System object™, H
.
This object maps each input value to a quantization region by comparing
the input value to the userspecified boundary points.
H = dsp.ScalarQuantizerEncoder('
returns
a scalar quantizer encoder object, PropertyName
',PropertyValue
,...)H
, with each specified
property set to the specified value.

Source of boundary points Specify how to determine the boundary points and codebook values
as 

Quantizer is bounded or unbounded Specify the quantizer as 

Boundary points of quantizer regions Specify the boundary points of quantizer regions as a vector.
The vector values must be in ascending order. Let 

Find quantizer index by linear or binary search Specify whether to find the appropriate quantizer index using
a linear search or a binary search as one of $${\text{log}}_{\text{2}}\text{(P)}$$ where P is
the number of boundary points. The default is 

Behavior when input equals boundary point Specify whether the input value is assigned to the lower indexed
region or higher indexed region when the input value equals boundary
point by selecting 

Enable output of codeword value Set this property to 

Enable output of quantization error Set this property to 

Codebook Specify the codebook as a vector of quantized output values
that correspond to each region. If the 

Enable output of clipping status Set this property to 

Data type of the index output Specify the data type of the index output from the object as: 
clone  Create an instance of an object with the same property values 
getNumInputs  Number of expected inputs to step method 
getNumOutputs  Number of outputs of step method 
isLocked  Locked status for input attributes and nontunable properties 
release  Allow property value and input characteristics changes 
step  Encode using scalar quantization 
Quantize the varying fractional inputs between zero and five to the closest integers, and then plot the results:
hsqe = dsp.ScalarQuantizerEncoder; hsqe.BoundaryPoints = [.001 .499 1.499 ... 2.499 3.499 4.499 5.001]; hsqe.CodewordOutputPort = true; hsqe.Codebook = [0 1 2 3 4 5]; input = (0:0.02:5)'; [index, quantizedValue] = step(hsqe, input); plot(1:length(input), [input quantizedValue]);
This object implements the algorithm, inputs, and outputs described on the Scalar Quantizer Encoder block reference page. The object properties correspond to the block parameters.