cdv.m

来自「一些用matlab编写的经典遗传算法算例。可以用于解决许多优化问题」· M 代码 · 共 34 行

M
34
字号
function c = cdv(varargin)
% CDV - Constructor for the class cdv, a sub class of the gen class.
% The constructor is called as follows:
%
% cdv('name',low_limit,high_limit,bits) 
% 'name' - the name that identify the variable
% low_limit - the lower limit for the variable
% high_limit - the upper limit for the variable
% bits - the number of bits used to code the variable
%
% if the constructor is called without any arguments it returns an
% empty variable.
% 
% See also CHROM,DDV,UI_GEN,UI_CHROM
switch nargin
 case 0
  c=struct('l_limit',0,'u_limit',0);
  c = class(c,'cdv',gen);
 case 1
  if isa(v,'cdv')
    c=varargin{1};
  else
    error('wrong argument')
  end
 case 4
  c=struct('l_limit',varargin{2},'u_limit',varargin{3});
  c=class(c,'cdv',gen(varargin{1},varargin{4}));
 otherwise
  error('Wrong number of arguments')
end



⌨️ 快捷键说明

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