The hess(f)
function in Matlab is used to calculate the Hessian matrix of a function f(x)
, which contains the second-order partial derivatives of f
with respect to each pair of variables.
Here is an example usage of hess
function:
main.m227 chars7 lines
This will output the following Hessian matrix:
main.m18 chars3 lines
Note that hess
can only be used for scalar functions of several variables, and the input to hess
must be a row vector of variables, not a column vector.
gistlibby LogSnag