NLP E Example
NLP Example
Unconstrained Example
Unconstrained Example
fminunc Consider the problem of finding a set of values [x1,x2]that solves Minimize f(x) X =ex1(4x,2+2x22+4xx2+2x2+1)
fminunc • Consider the problem of finding a set of values [x1, x2] that solves Minimize f ( x ) x =ex1 ( 4x 1 2 +2x 2 2 +4x 1 x 2 +2x 2 +1 )
To solve this two-dimensional problem, write an M-file that returns the function value Then,invoke the unconstrained minimization routine fminunc
• To solve this two-dimensional problem, write an M-file that returns the function value • Then, invoke the unconstrained minimization routine fminunc
Step 1:Write an M-file objfun.m function f objfun(x) f=eXp(x(1)*(4*x(1)2+2*x(2)^2+ 4*x(1)*x(2)+2*X(2)+1)
Step 1: Write an M-file objfun.m function f = objfun(x) f=exp(x(1))*(4*x(1)^2+2*x(2)^2+ 4*x(1)*x(2)+2*x(2)+1)