matlab解非线性方程

This example finds a zero of the system of two equations and two unknowns:

clip_image002

clip_image002[4]

You want to solve the following system

clip_image002[6]

clip_image002[8]

for x  starting at x0 = [-5 -5].

First, write an M-file that computes F, the values of the equations at x. function F = myfun(x)
F = [2*x(1) - x(2) - exp(-x(1));
      -x(1) + 2*x(2) - exp(-x(2))];


Next, call an optimization routine. x0 = [-5; -5];           % Make a starting guess at the solution
options=optimset('Display','iter');   % Option to display output
[x,fval] = fsolve(@myfun,x0,options)  % Call optimizer

posted on 2011-01-31 15:45  carekee  阅读(570)  评论(0)    收藏  举报