continuous plot of minimization results

Hello,
I'd like to run the fminsearch solver for a couple of times and plot the progress of the minimization (the residual terms) incessantly:
options=optimset('PlotFcns',@plot_optim_out,'MaxIter',100);
for i=1:5
[x_iter,~,~,output]=fminsearch(fun,x_iter,options);
ii=ii+output.iterations;
end
function [stop] = plot_optim_out(~,optimValues,~)
global P_diff; global P_hom; global P_c1;
i=optimValues.iteration+evalin('base','ii');
stop = false;
hold on;
plot(i,P_diff/P_c1,'b*',i,P_hom/P_c1,'go');
set(gca,'yscale','log');
drawnow;
end
The plot continues to count, but the axis refreshes, so the plot "forgets" the previous data points. Does anybody have an idea why?
Regards

Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Asked:

on 20 Mar 2019

Community Treasure Hunt

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

Start Hunting!