gaplotbestfun.m

来自「关于遗传算法(GA)的相关内容介绍(英文资料)以及算法工具箱」· M 代码 · 共 27 行

M
27
字号
function state = gaplotbestfun(options,state,flag)%GAPLOTBESTF Plots the best score and the mean score.%   STATE = PLOTBEST(OPTIONS,STATE,FLAG) plots the best score as well%   as the mean of the scores.%%   Example:%    Create an options structure that will use PLOTBEST%    as the plot function%     options = gaoptimset('PlotFcns',@plotbest);%   Copyright 2004 The MathWorks, Inc. %   $Revision: 1.9 $  $Date: 2004/01/16 16:51:50 $if(strcmp(flag,'init'))    set(gca,'xlim',[1,options.Generations]);    xlabel('Generation','interp','none');    grid on    ylabel('Fitness value','interp','none');endhold on;generation = state.Generation;best = min(state.Score);plot(generation,best, 'v');title(['Best: ',num2str(best)],'interp','none')hold off;        

⌨️ 快捷键说明

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