Lookup Table Using Flat Interpolation can be used for arbitrary quantization to a set of specified quantization values. Practically, you don't want the set of values to be too big.
The output vector and breakpoint vector for the lookup table can be defined like so. (Full code attached).
vecDesiredQuantizationValues = unique([
vecBreakPointsNearestViaFlatInterp = vecDesiredQuantizationValues;
vecBreakPointsNearestViaFlatInterp(2:end) = 0.5*(vecDesiredQuantizationValues(1:(end-1))+vecDesiredQuantizationValues(2:end));
A simple model to test this is attached.
The response of this model shows that quantization to the arbitrary set of values is achieved.
Alternate Approach Algorithm
If the number of values to quantize too is large, and you can describe the set of quantization values by math formulas, then an algorithm approach can be used.
Write down the equations, then synthesizes those equations using Simulink blocks, or via MATLAB code and put that in a MATLAB function block.
Example, quantize to values in the sequence
x_i = 1.35.^i for i is an integer from -10 to 10
This logrithmically spaced quantization could be implemented by this algorithm
function y = quantLogarithmic(u)
k = 1.35;
iLo = -10;
iHi = 10;
log2k = log2(k);
lo = k.^iLo;
hi = k.^iHi;
u2 = min(hi,max(lo,u));
i = round( log2(u2) ./ log2k );
y = k.^i;
This can be tested via the attached script test_quantLogarithmic which produces this graph.
Don't let the uniform spacing of the plot fool you. It is not uniform on regular linear spaced graph. The algorithmic approach is not limited to logarithmic spacing. It's only limited by your ability to manipulate your formulas and put the inner quantization in the right spot.