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

4 ビュー (過去 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);
and
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();
end
case 'done'
if ~isempty(h) && isvalid(h)
delete(ancestor(h), 'figure');
end
case 'iter'
if isvalid(h)
addpoints(h, X(1), X(2), OPTIMVALUES.fval);
end
case 'interupt'
%no new data
end
end
  16 件のコメント
Jorge Armando Vazquez
Jorge Armando Vazquez 2021 年 5 月 15 日
I have been trying to run the program many times, and there appears no error but the program doesn´t stop running so I dont get the final plot, you think maybe if is by the way where for every minimization step, graph for "all" of the values between p0 and par_optimos(1:2) may works.
Walter Roberson
Walter Roberson 2021 年 5 月 15 日
I do not see your code for FunObjetivo ?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by