MATLAB: How to quantize a row matrix of 15 elements to 1024 levels and then code using 10 bits(binary)

codingquantization

So i have a row matrix of 15 elements and i want to quantize each of these elements to one of 1024 levels. and further code these levels using 10 bits. kind of similar to how samples of a signal are coded for A/D conversion. Thank you.

Best Answer

discretize to do the quantisation, dec2bin to do the conversion to binary:
data = rand(1 ,15); %demo data
levels = linspace(0, 1, 1024); %replace with whatever definition you have for your levels
quantiseddata = discretize(data, levels);
binarydata = dec2bin(quantiseddata, 10) %each row is a binary string of the respective original value
If you want binarydata as an matrix of 0 and 1 (as opposed to char '0' and '1'):
binarydata = binarydata - '0' %rows are original numbers, columns are bits