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

📄 logbook.m

📁 一些用matlab编写的经典遗传算法算例 挺有用的
💻 M
字号:
function logbook(fname,chr,generation)
% LOG - logs to file 
%   log('fname',chr,generation) logs the current population to file
%   named 'fname', chr are the chromosomes, generation is the number
%   of the current generation.
if generation==1
  fid=fopen(fname,'w');
  fprintf(fid,'Total generations: %g\n',generation);
  fseek(fid,1,0);
  csave(fid,chr,generation);
  fclose(fid);
else 
  fid=fopen(fname,'r+');
  fgetl(fid);
  t=fgetl(fid);
  frewind(fid);
  fprintf(fid,'Total generations: %g\n',generation);
  fprintf(fid,strcat(t,'\n'));
  fseek(fid,0,1);
    csave(fid,chr,generation);
  fclose(fid);
end

⌨️ 快捷键说明

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