To find the critical values and classify them as minimum, maximum or saddle points for a multi-variable function in MATLAB, you can follow these steps:
main.m37 chars3 lines
gradient
function to find the gradient of the function.main.m29 chars2 lines
main.m43 chars2 lines
main.m28 chars2 lines
For each critical point, perform the following steps: 5.1. Evaluate the eigenvalues of the Hessian matrix.
main.m32 chars2 lines
5.2. Determine the nature of the critical point based on the eigenvalues: * If all eigenvalues are positive, the point is a local minimum. * If all eigenvalues are negative, the point is a local maximum. * If there are both positive and negative eigenvalues, the point is a saddle point. * If any eigenvalue is zero, further analysis is needed.
Here's the complete code:
main.m720 chars21 lines
Note that the function eig
in MATLAB returns the eigenvalues of a matrix and eval(subs(hess_f,[x,y],s))
evaluates the Hessian matrix at a given point (x,y) = s
.
gistlibby LogSnag