how to quantize a row matrix of 15 elements to 1024 levels and then code using 10 bits(binary)?

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.

 Accepted 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

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!