Plot function within optimisation algorithm does not work with subplots -
이전 댓글 표시
Hello, I am trying to visualise optimisation progress, where the mathematical model is fitted onto measured data. By using only one set of axes, the function works with no problems. Whenever I try to implement subplots to plot multiple values into one figure, I get the following error:
Error using optim.problemdef.OptimizationProblem/solve - Invalid or deleted object.
I am using lsqnonlin function, the options of which are defined by the following:
lsqoptions = optimoptions("lsqnonlin",...
Display = "iter-detailed",...
MaxIterations = 1.5e4,...
MaxFunctionEvaluations = 1e5,...
FunctionTolerance = 1e-18,...
StepTolerance = 1e-18...
);
lsqoptions.PlotFcn = @(x, optimValues, flag) plotprogress(x, optimValues, flag, ipe, plotting, ord, freq, stor_mod, loss_mod, dyn_mod, E);
Within the plotprogress function,I define variables to be plotted along with several other quantities. When trying to plot with subplots, the plot function looks like this:
function out = plotprogress(varargin)
% extracting variables from varargin....
% plotting
ax = subplot(3,1,3);
plotting.count = 1;
for i = 0:18:73
semilogx(ax,freq(i+1:i+18),dyn_mod(i+1:i+18),'.','LineWidth',2,'MarkerSize',25,'Color',plotting.dotcol(plotting.count,:)); hold on; grid on;
plotting.count = plotting.count+1;
end
semilogx(ax,freq,dyn_num,'LineWidth',2,Color=ipe.darkred)
hold off;
legend('20C','10C','0C','-10C','-20C','fit','Location','northwest')
xlabel('f_{master}')
ylabel('Dynamic modulus master')
out = false;
end
Every variable is defined, so this should not be a problem. Whenever I change the ax = subplot(3,1,3); into ax = gca; the plot function seems to be working with no problems whatsoever.
댓글 수: 2
Jan
2022년 11월 16일
Please post a copy of the complete message, which reveals, in which line the error occur. Sharing this important inforamtion with the readers ist a good idea.
Ondrej Farkas
2022년 11월 16일
편집: Ondrej Farkas
2022년 11월 16일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
