?? plot.m
字號:
function plot(chr,varargin)% PLOT - plots the generations. % plot(chr,arch) plots the best member in each generation as well as% the average value of the population. The argument chr should be a% mxn matrix with m generations and n chromosomes. The second% argument arch should be a vector consisting of the prototypes of% the different species. If specified the best of each species in% each generation are plotted in a separate figure. If not specified% only the best and the average values are plotted.figurea=mean(chr);m=max(chr);plot(m);xlabel('Generation')hold on title('Max and average fitness for the population');plot(a,'r');ylabel('Fitness')legend('max','average',4)colour={'b' 'r-.' 'm:' 'k' 'c' 'g' 'y' };if ~isempty(varargin) figure title('Max values of each species') hold on [m n]=size(chr); for k=1:length(varargin{1}) name=get(varargin{1}(k),'name'); leg{k}=strcat('Species: ',name); for l=1:m tmp_ind=find(chr(l,:),name); if tmp_ind tmp_pop=chr(l,tmp_ind); ma(l)=max(tmp_pop); mi(l)=min(tmp_pop); end end plot(ma,colour{k}); xlabel('Generation') ylabel('Fitness') end legend(leg,4) %Plot of nmbr of # members in the generations figure title('Distribution of members') hold on for j=1:length(varargin{1}) name=get(varargin{1}(j),'name'); leg{j}=strcat('Species: ',name); for i=1:m tmp=find(chr(i,:),name); if tmp(1)~=0 nmbr(i)=length(tmp); else nmbr(i)=0; end end plot(1:m,nmbr,colour{j}) end xlabel('Generation') ylabel('# of members') legend(leg,4)end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -