how to make a 4 bits quantizer with 15 levels
Show older comments
im working in project that i should make a 4 bits quantizers with 15 levels and encoding each levels with a binary sequence of 4 bits:
can i have some idea please. thank you
Answers (1)
Walter Roberson
on 11 Jan 2021
0 votes
discretize() and dec2bin
Or is this a Simulink question?
7 Comments
mohamed chahma
on 12 Jan 2021
Image Analyst
on 12 Jan 2021
For your 15 levels, what value do you want mapped to 0 and what value do you want mapped to 14? Or do you want 16 values between and including 0 to 15? Anyway, I don't see any additional question so I imagine you're looking at discretize() right now. So if that works for you, which it should, then please "Accept this answer" to give Walter credit.
mohamed chahma
on 12 Jan 2021
Walter Roberson
on 12 Jan 2021
So 1111 represents all values that are negative?
discretize to get a bin number. Use the bin numbers as row indices into a 2d array with 16 rows and 4 columns.
mohamed chahma
on 12 Jan 2021
Walter Roberson
on 12 Jan 2021
We are going to need a list of voltages and associated bit patterns. Please be specific about whether any particular voltage < or <= .
You have indicated that your signal is -1 to +1 . You have indicated that you want 0 exactly to be 0000 and that you want 1 exactly to be 1000 and that 1111 will not be used. What about values between -1 (exactly) and 0 (excluded)? What will be represented by 1001 1010 1011 1100 1101 1110 ?
format long g
bitpatterns = dec2bin(0:15,4) - '0';
bitpatterns = bitpatterns(randperm(15),:)
boundaries = [-1 sort(rand(1,14)*2-1) 1];
mat2str(boundaries)
t = sort(rand(1,10));
mat2str(t)
signal = cos(3*t*pi);
mat2str(signal)
plot(t, signal, '*-')
bin = discretize(signal, boundaries)
m_arry = bitpatterns(bin,:)
Categories
Find more on Cast and Quantize Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!