Professional Documents
Culture Documents
Solving Nonlinear Equation(s) in MATLAB: Chee 222: Process Dynamics and Numerical Methods
Solving Nonlinear Equation(s) in MATLAB: Chee 222: Process Dynamics and Numerical Methods
NOTE: In utilizing ROOTS function, all coefficients of the polynomial must be specified. e.g. f(x) = x4 - 3x2 +2. The function in the full polynomial form must be expressed as: f(x) = 1 x4 - 0 x3 +3 x2 -0 x + 2. Accordingly, the polynomial must be defined in MATLAB as follows: p = [1 0 -3 0 2]:
5 FSOLVE
The MATLAB routine fsolve is used to solve sets of nonlinear algebraic equations using a quasi-Newton method. The user must supply a routine to evaluate the function vector. Consider the following system of nonlinear equations, and solve for x1 and x2:
f1 ( x1 , x 2 ) = x1 4 x12 x1 x 2
2 f 2 ( x1 , x 2 ) = 2 x 2 x 2 3 x1 x 2
The m-file used to solve the above problem using fsolve is:
xo = [11]'
Note: xo is the TRANSPOSE of a row vector Now, solve with x = fsolve(nle; x0)