matlab - Use fminsearch to find local minimizer and the minima at that value -


i having trouble using fminsearch: getting error there not enough input arguments function.

f = @(x1,x2,x3) x1.^2 + 3.*x2.^2 + 4.*x3.^2 - 2.*x1.*x2 + 5.*x1 + 3.*x2 + 2.*x3; [x, val] = fminsearch(f,0) 

is there wrong function? keep getting errors anytime want use input function other command.

i having trouble using fminsearch [...]

stop right there , think more function you're trying minimize.

numerical optimization (which fminsearch does) unnecessary, here. function quadratic function of vector x; in other words, value @ x can expressed as

x^t x + b^t x 

where matrix a , vector b defined follows (using matlab notation):

a = [ 1 -1 0;      -1  3 0;       0  0 4] 

and

b = [5 3 2].' 

because a positive definite, function has 1 , 1 minimum, can computed in matlab with

x_sol = -0.5 * \ b; 

now, if you're curious cause of error ran into, have @ fuesika's answer; without fminsearch whenever can.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -