⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 num2bit.m

📁 一个启发式搜索算法  给初学者用的 随便参考着用  提供了多种策略
💻 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 + -