1. Write a function in MATLAB that minimizes a multi-dimensional problem using t
ID: 670422 • Letter: 1
Question
1. Write a function in MATLAB that minimizes a multi-dimensional problem using the steepest descent method (see section 6.2.1). The function should be called as: [x,iter,addl] = mySteepestDescent(f,g,x0,tol,MaxIter) Where: f is the objective function g is the gradient of the objective function (a vector of partial derivatives of the objective function with respect to x(1), x(2), …, x(n) x0 is a vector of initial guesses tol is your tolerance MaxIter is the maximum number of iterations addl is a matrix of additional output, such as the function value at each iteration
f2(x,y) = 100(y – x2)2 + (1 – x)2
Explanation / Answer
Solution :
function stop = binChoicePlot(x,optimvalues,state)
if(length(x)==2)
if (optimvalues.iteration==0)
hold off;
end
grad = optimvalues.gradient;
f = optimvalues.fval;
plot3(f,x(1),x(2),'k*');
if (optimvalues.iteration==0)
hold on;
end
quiver3(f,x(1),x(2),0,grad(1),grad(2));
drawnow
pause(0.5);
end
stop = false;
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.