Page 25 - Algorithm Collections for Digital Signal Processing Applications using MATLAB
P. 25

1. Artificial Intelligence                                        13

           pop1=col2;
               s=fcn(pop);
               plot(pop,s)
               [u,v]=max(fcn(pop1));
               BEST=[BEST;pop1(v(1)) fcn(pop1(v(1)))];
               hold on
               plot(pop1,fcn(pop1),'r.');
               M(iter)=getframe;
               pause(0.3)
               hold off
               [iter pop1(v(1)) fcn(pop1(v(1)))]
           end
           for i=1:1:14
               D(:,:,:,i)=M(i).cdata;
           end
           figure
           imshow(M(1).cdata)
           figure
           imshow(M(4).cdata)
           figure
           imshow(M(10).cdata)
           figure
           imshow(M(30).cdata)

           ___________________________________________________________________________

           fcn.m

           function [res]=fcn(x)
           res=x+10*sin(5*x)+7*cos(4*x)+sin(x);


           Note that the m-file fcn.m may be edited for changing the fitness function


           2.2.2    Program illustration

           The following is the sample results  obtained during the execution of the
           program geneticgv.m
   20   21   22   23   24   25   26   27   28   29   30