Package: dsp
Vector quantization encoding
The VectorQuantizerEncoder
object performs
vector quantization encoding. The object finds the nearest codeword
by computing a distortion based on Euclidean or weighted Euclidean
distance.
To perform vector quantization encoding:
Define and set up your vector quantizer encoder. See Construction.
Call step
to perform the quantization
encoding according to the properties of dsp.VectorQuantizerEncoder
.
The behavior of step
is specific to each object in
the toolbox.
H = dsp.VectorQuantizerEncoder
returns
a vector quantizer encoder System object™, H
.
This object finds a zerobased index of the nearest codeword for each
given input column vector.
H = dsp.VectorQuantizerEncoder(
returns
a vector quantizer encoder System object, 'PropertyName'
,PropertyValue
,...)H
,
with each specified property set to the specified value.

Source of codebook values Specify how to determine the codebook values as 

Codebook Specify the codebook to which the input column vector or matrix
is compared, as a kbyN matrix.
Each column of the codebook matrix is a codeword, and each codeword
corresponds to an index value. The codeword vectors must have the
same number of rows as the input. The first codeword vector corresponds
to an index value of $$\left[\begin{array}{l}\text{1}\text{.513}\text{.3136}\text{.46}\text{.8}\\ \text{2}\text{.514}\text{.3137}\text{.47}\text{.8}\\ \text{3}\text{.515}\text{.3138}\text{.48}\text{.8}\end{array}\right]$$ This property is tunable. 

Distortion calculation method Specify how to calculate the distortion as 

Source of weighting factor Specify how to determine weighting factor as 

Weighting factor Specify the weighting factor as a vector of length equal to
the number of rows of the input. This property applies when you set
the 

Behavior when input column vector is equidistant from two codewords. Specify whether to represent the input column vector by the
lower index valued codeword or higher indexed valued codeword when
an input column vector is equidistant from two codewords. You can
set this property to 

Enable output of codeword value Set this property to 

Enable output of quantization error Set this property to 

Data type of index output Specify the data type of the index output as: 
clone  Create vector quantizer encoder object with 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  Perform vector quantization encoding 
Find the indices of nearest codewords based on Euclidean distances:
hvqenc = dsp.VectorQuantizerEncoder(... 'Codebook', [1 1 1 1;1 1 1 1], ... 'CodewordOutputPort', true, ... 'QuantizationErrorOutputPort', true, ... 'OutputIndexDataType', 'uint8'); % Generate an input signal with some additive noise x = sign(rand(2,40)0.5) + 0.1*randn(2,40); [ind, cw, err] = step(hvqenc, x); plot(cw(1,:), cw(2,:), 'rO', x(1,:), x(2,:), 'g.'); legend('Quantized', 'Inputs', 'location', 'best');
This object implements the algorithm, inputs, and outputs described on the Vector Quantizer Encoder block reference page. The object properties correspond to the block parameters.