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

📄 ga_rand.m

📁 其中提到遺傳學的程式碼與應用提供給次淚相向的研究者參考下載
💻 M
字号:
function randValue=GA_rand(value,DIR);
%% randValue=GA_rand(value,DIR);
%% value must be a scalar.
%% If DIR== 1, return a numeric greater than value
%% If DIR==-1, return a numeric smaller than value
%% If DIR== 0, return a randon numeric
%% For example:
%value=3;DIR=-1;
%randValue=GA_rand(value,DIR)

% PenChen Chou. 2004-10-29

if nargin==1, DIR=0; end
[m,n]=size(value); 
if m*n~=1, error('==>ERROR! value must must be a scalar.'); end
if DIR==1 | DIR==0 | DIR==-1, 
    ;
else
    error ('DIR must be -1/0/1'); 
end
rand('state',sum(100*clock));
if value>0
    LB=0.5*value; UB=2*value;
elseif value<0
    LB=2*value; UB=0.5*value;
else
    LB=-0.005*ones(size(value)); UB=0.005*ones(size(value));
end
OK=0;
while ~OK
   randValue=(UB-LB)*rand+LB;
   if DIR==0, OK=1; end
   if randValue>1.50*value & DIR== 1, OK=1; end
   if randValue<0.67*value & DIR==-1, OK=1; end
   if value==0, OK=1; end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -