我正在使用以下功能和fminunc
来绘制情节
function stop = bananaout(x, optimValues, state)
stop = false;
hold on;
plot(x(1),x(2),'.');
drawnow
end
我的情节如下所示,
如何让它看起来如下?
我是否需要修改我的bananaout
或驱动程序?
源代码
function [x, fval, eflag, iter, fcount] = Optimization_With_Steepest_Descent(start_point)
fun = @(x)(100*(x(2) - x(1)^2)^2 + (1 - x(1))^2);
x0 = start_point;
% optimoptions setup
options = optimoptions('fminunc','Display','off', 'OutputFcn',@bananaout,'Algorithm','quasi-newton');
options = optimoptions(options,'HessUpdate','steepdesc', 'MaxFunEvals',600);
% call fminunc
[x,fval,eflag,output] = fminunc(fun,x0,options);
title 'Rosenbrock solution via steepest descent'
iter = output.iterations;
fcount = output.funcCount;
disp('Press any key to continue...');
end