Mathematics | ![]() ![]() |
Minimizing Functions of Several Variables
The fminsearch
function is similar to fminbnd
except that it handles functions of many variables, and you specify a starting vector x0 rather than a starting interval. fminsearch
attempts to return a vector x that is a local minimizer of the mathematical function near this starting vector.
To try fminsearch
, create a function three_var
of three variables, x
, y
, and z
.
function b = three_var(v) x = v(1); y = v(2); z = v(3); b = x.^2 + 2.5*sin(y) - z^2*x^2*y^2;
Now find a minimum for this function using x = -0.6
, y = -1.2
, and z = 0.135
as the starting values.
v = [-0.6 -1.2 0.135]; a = fminsearch(@three_var,v) a = 0.0000 -1.5708 0.1803
![]() | Minimizing Functions of One Variable | Setting Minimization Options | ![]() |