MATLAB: Output history and testing convergence

convergencegraphshistoryiterationsoutputwhile loop

Hi there,
I have quite a complicated algorithm running and I would like to test to see if it converges as it is taking a very long time to run. How do I go about using my output from my while loops on each iteration, putting them into a graph so I can see if they converge??

Best Answer

x=nan(1,MaxIterations);
while i<=MaxIterations
...
x(i)=...
plot(x), drawnow
i=i+1
end
However, it's debatable whether this can give you true information about convergence, if you don't know what x(i) is converging to.
Related Question