get.m

来自「多目标遗传算法/用法不用多说、要用的赶快下载吧」· M 代码 · 共 53 行

M
53
字号
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  endend

⌨️ 快捷键说明

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