I need to store every iteration in curve using plot

1 回表示 (過去 30 日間)
Bathrinath
Bathrinath 2014 年 5 月 17 日
コメント済み: Bathrinath 2014 年 5 月 17 日
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)

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 5 月 17 日
In side the loop, just after BestFitness = min(fitness) ; add
Y1(i)= BestFitness
Then after the loop
X1=1:NVAR
plot(X1,Y1)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Fourier and Cosine Transforms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by