MATLAB Answers

I need to create a 3d plot with each step of fminsearch

조회 수: 1(최근 30일)
Jorge Armando Vazquez
Jorge Armando Vazquez 2021년 5월 10일
댓글: Walter Roberson 2021년 5월 15일
Hi, here is my program
par0 = [0.005276, 0.5017, 88.6357];% initial values
fun_objetivo = @(par,pfrac)FunObjetivo(par);
options = optimset('MaxFunEvals',3000,'Display','iter','PlotFcns',@optimplotfval);
%We use here the Nelder-Mead method
par_optimos = fminsearch(fun_objetivo, par0, options);
I need help with some comands to create a 3d plot, what I want is a 3d plot with "par_optimos(1)" as X, "par_optimos(2)" as Y and "min f(x)" as Z , so I can see how two of the values of my vector "par_optimos" are optimized in each iteration.

채택된 답변

Walter Roberson
Walter Roberson 2021년 5월 10일
options = optimset('MaxFunEvals',3000,'Display','iter','PlotFcns',@plot_12z);
function stop = plot_12z(X,OPTIMVALUES,STATE)
persistent h
stop = false;
switch STATE
case 'init'
if isempty(h) || ~isvalid(h)
fig = figure();
ax = axes(fig);
h = animatedline();
case 'done'
if ~isempty(h) && isvalid(h)
delete(ancestor(h), 'figure');
case 'iter'
if isvalid(h)
addpoints(h, X(1), X(2), OPTIMVALUES.fval);
case 'interupt'
%no new data
  댓글 수: 16
Walter Roberson
Walter Roberson 2021년 5월 15일
I do not see your code for FunObjetivo ?

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by