当我尝试将十进制数(例如 1.571)转换为二进制时,对于所有非整数值,我得到 0。有没有办法在MATLAB中以二进制显示小数?
这是我的代码的摘录:
%The region between 0 and 2*pi is split up into 40 sections
N=20;
%The step is an the incrementation amount of the calculated sin
step= (2*pi)/40
%Cycle through and calculate the sin at each step
for i=1:N
C_r(i) = sin(step*i)
end
for i = 1 : N
str_r = dec2bin(C_r(i),24);
end