You can do non-uniform quantization of arrays in multiple ways:
- histc passing in bin edges
- hist passing in bin centers
- histcounts() passing in either bin edges or bin centers with appropriate options
In the above three cases, you want to extract the bin number, which is the second output for histc or hist and the third output for histcounts. You then use the bin number as an index into an array of the representative value for each bin.
You can also quantize over arrays by using interp1() with the 'previous' or 'next' or 'nearest' option, like interp1(edges_list, representative_values_list, array_to_quantize, 'previous') . Here representative_values would be the same as the edges list if you wanted to quantize to the edge value but would be the edge centers if you wanted to quantize to the edge centers.