how to make a 4 bits quantizer with 15 levels

7 views (last 30 days)
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
Walter Roberson on 11 Jan 2021
discretize() and dec2bin
Or is this a Simulink question?
  7 Comments
Walter Roberson
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 ?
Walter Roberson
Walter Roberson on 12 Jan 2021
format long g
bitpatterns = dec2bin(0:15,4) - '0';
bitpatterns = bitpatterns(randperm(15),:)
bitpatterns = 15×4
1 1 0 1 0 1 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1
boundaries = [-1 sort(rand(1,14)*2-1) 1];
mat2str(boundaries)
ans = '[-1 -0.884897455427377 -0.805515680810448 -0.52755891710828 -0.457066695586775 -0.421367409673541 -0.413658951403185 -0.256435083908991 -0.255358677307649 -0.187772339939494 -0.079464055460132 0.15663450872117 0.281287350041566 0.588341090826803 0.786210928528617 1]'
t = sort(rand(1,10));
mat2str(t)
ans = '[0.021032837054374 0.105139509835107 0.16540077837713 0.18325666397305 0.552700488919609 0.658471471291779 0.659400298626749 0.661681959007068 0.662279200025889 0.780426713723395]'
signal = cos(3*t*pi);
mat2str(signal)
ans = '[0.980416722769212 0.547923383075194 0.011930433013734 -0.15572072886789 0.476518476686621 0.99701863625309 0.997655893732092 0.998896653894506 0.999145173395954 0.478225560797132]'
plot(t, signal, '*-')
bin = discretize(signal, boundaries)
bin = 1×10
15 13 11 10 13 15 15 15 15 13
m_arry = bitpatterns(bin,:)
m_arry = 10×4
1 0 1 1 0 1 0 1 1 0 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 0 1 0 1

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!