I need to store every iteration in curve using plot

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)

 Réponse acceptée

In side the loop, just after BestFitness = min(fitness) ; add
Y1(i)= BestFitness
Then after the loop
X1=1:NVAR
plot(X1,Y1)

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by