📄 num2bit.m
字号:
function y=num2bit(th_element,b,thetmin,thetmax)
%This function takes a real number and converts it to a b-bit
%representation. The value b is chosen in GAbit_roulette to satisfy
%the decimal accuracy requirements given in M (as in step 1 of encoding
%process of Subsection 9.3.2 of ISSO).
%
d=(thetmax-thetmin)/(2^b-1);
rnd=round((th_element-thetmin)/d);
y=zeros(1,b);
for i=b:-1:1
ratio=rnd/(2^(i-1));
if ratio >= 1
y(b-i+1)=1;
rnd=rnd-2^(i-1);
else
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -