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

回答(0 个)

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

提问:

2019-3-20

Community Treasure Hunt

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

Start Hunting!

Translated by