load_mut.m

来自「一些用matlab编写的经典遗传算法算例 挺有用的」· M 代码 · 共 35 行

M
35
字号
function mutinfo = load_mut(fname)
% LOAD_MUT - loads mutation information from file
%   load_mut('fname') returns the mutation information saved in the
%   file 'fname'.  

index=1;
fid=fopen(fname);
fgetl(fid);
fgetl(fid);

while ~feof(fid)
  str=fgetl(fid);
  mutinfo(index).name=str(7:end);
  str=fgetl(fid);
  if length(str)==8
    mutinfo(index).mut_lim=[];
  else
    mutinfo(index).mut_lim=sscanf(str(8:end),'%g');
  end
  str=fgetl(fid);
  mutinfo(index).pc=sscanf(str(4:end),'%g');
  str=fgetl(fid);
  mutinfo(index).trans=sscanf(str(13:end),'%g');
  if mutinfo(index).trans==0
    mutinfo(index).trans=[];
  end
  str=fgetl(fid);
  mutinfo(index).relive=sscanf(str(8:end),'%g');
  fgetl(fid);
  index=index+1;
  
end
fclose(fid);

⌨️ 快捷键说明

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