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

📄 get.m

📁 一些用matlab编写的经典遗传算法算例 挺有用的
💻 M
字号:
function varargout =get(chr,varargin)
% GET - Returns the values of the chromosome corresponding to
% the property list. Any number of properties can be returned with one
% function call. 
%   
% [val1 val2 etc...]=get(chromosome,'property','property',etc..).  
% The properties are:
%
% 'name' - the name of the chromosome
% 'fitness' - the fitness of the chromosome
% 'cdvs' - the continuous design variables                                
% 'ddvs' - the discrete design variables  
%
% to list the valid properties for a certain object use get(gene)

tst=nargin;
if tst==1
  fprintf('Valid properties:\nname \nvalue \nbits\ndna\nid\nk')
else

  if ~or(or(tst==2,tst==3),tst==4)
    error('bad number of arguments')
  end
  for k=1:tst-1
    switch varargin{k}
   case 'name'
    varargout{k}=chr.name;
     case 'fitness'
      varargout{k}=chr.fitness;
     case 'cdvs' 
      varargout{k}=chr.cdvs;
     case 'ddvs'
      varargout{k}=chr.ddvs;
     case 'id'
      varargout{k}=chr.id;
     otherwise
      txt=strcat('bad argument:',varargin{k});
      error(txt)
    end
  end
end











⌨️ 快捷键说明

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