MATLAB: What function can I use here to convert the negative, non-negative value of quantized signal into Binary number

discreet signalmatlab function

I do not want to use Dec2bin and using comple is not being helpful so what should I do?
B=6; %bit number
L=2^B; %number of levels
w=2*pi;
m=pi/6;
n=0:1:30
x=sin(w*0.1*n+m);
y=round(x)
%Quantization starts
x1=x-min(x)
x2=x1/(max(x)-min(x))
x3=x2*(L-1)
x4=round(x3)
x5=x4/(L-1)
x6=x5*(max(x)-min(x))
x7=x6+min(x)
%quantized signal
figure
stem(x7,'r')
title('the Quantized levels')
xlabel('Sample Number, n')
ylabel('Quantized levels')
%Binary representation of the data

Best Answer

Once you had the bin number, you would subtract 1 (because bin numbers cannot be 0) and convert the result to binary.