Quantize signal using partition and codebook
Source Coding
The Quantizing Encoder block quantizes the input signal according to the Partition vector and encodes the input signal according to the Codebook vector. This block processes each vector element independently. The input must be a discretetime signal. This block processes each vector element independently. For information about the data types each block port supports, see the Supported Data Type table on this page.
The first output is the quantization index. The second output is the quantized signal. The values for the quantized signal are taken from the Codebook vector.
The Quantization partition parameter, P, is a real vector of length n whose entries are in strictly ascending order. The quantization index (second output signal value) corresponding to an input value of x is
0 if x ⩽ P(1)
m if P(m) < x ⩽ P(m+1)
n if P(n) < x
The Quantization codebook parameter, whose length is n+1, prescribes a value for each partition in the quantization. The first element of Quantization codebook is the value for the interval between negative infinity and the first element of P. The second output signal from this block contains the quantization of the input signal based on the quantization indices and prescribed values.
You can use the function lloyds
in
Communications System Toolbox with a representative sample of your
data as training data, to obtain appropriate partition and codebook
parameters.
The vector of endpoints of the partition intervals.
The vector of output values assigned to each partition.
Select the output data type.
Port  Supported Data Types 

U 

Idx 

Q(U) 

Scalar Quantizer (Obsolete) (DSP System Toolbox™ documentation), lloyds
(Communications System Toolbox™ documentation)