%% Quantize Signal
% 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).
% 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)

% Copyright 2012 The MathWorks, Inc.