Saturday 16 February 2013

Solving multivariable equations with MATLAB: An example


function fcn = mul_equ(u)

x = u(1);
y = u(2);

fcn(1)= x.^2 +2*y.^2-5*x+7*y-40;
fcn(2) = 3*x.^2-y.^2+4*x+2*y-28;

%result = fsolve(@mul_equ,guess)
%[result,fval,exit flag,output]= fsolve(@mul_equ,guess)

output is:


>> [result,fval,exit flag,output]= fsolve(@mul_equ,guess)
Optimization terminated: first-order optimality is less than options.TolFun.

result =

    2.6963    3.3655


fval =

  1.0e-008 *

    0.5849   -0.2216


exit =

     1


flag =

       iterations: 5
        funcCount: 18
        algorithm: 'trust-region dogleg'
    firstorderopt: 1.3017e-007
          message: 'Optimization terminated: first-order optimality is less than options.TolFun.'


output =

    0.3926   20.4620
   20.1779   -4.7310



No comments:

Post a Comment