I need to store every iteration in curve using plot
Show older comments
For every iteration i want to store values in x and y axis, where x is number of iteration and y is BestFitness.I have given the code where i tried by myself it couldnt happen. Give some valuable solution.
function MainHar
X1=[]; %x axis for the number of iteration
Y1=[]; %y axis for the BestFitness
initialize;
currentIteration = 0;
while(StopCondition(currentIteration))
PAR=(PARmax-PARmin)/(MaxItr)*currentIteration+PARmin;
coef=log(bwmin/bwmax)/MaxItr;
for pp =1:NVAR
BW(pp)=bwmax*exp(coef*currentIteration);
end
% improvisation
for i =1:NVAR
ran = rand(1);
if( ran < HMCR ) % mem con
index = randint(1,HMS);
NCHV(i) = HM(index,i);
pvbRan = rand(1);
if( pvbRan < PAR) % pit
pvbRan1 = rand(1);
result = NCHV(i);
if( pvbRan1 < 0.5)
result =result+ rand(1) * BW(i);
if( result < PVB(i,2))
NCHV(i) = result;
end
else
result =result- rand(1) * BW(i);
if( result > PVB(i,1))
NCHV(i) = result;
end
end
end
else
NCHV(i) = randval( PVB(i,1), PVB(i,2) ); % random selection
end
end
newFitness = Fitness(NCHV);
UpdateHM( newFitness );
currentIteration=currentIteration+1;
end
BestFitness = min(fitness);
end
plot(X1,Y1)
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!