How to Use Matlab for the Gauss-Newton Method

Written by claire jameson
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Use Matlab for the Gauss-Newton Method
Use computer software to perform calculations quickly. (computer image by fotografiche.eu from Fotolia.com)

The Gauss-Newton method is a nonlinear least squares algorithm. The process involves making a series of guesses as to the value of x, then linearising an equation, say r, near the guesses. The result leads to a new guess, which is a linear least squares solution. The algorithm is repeated until convergence occurs. Performing this method by hand can be arduous process; the use of software such as MathWorks Matlab can perform complicated calculations in a much shorter amount of time.

Skill level:
Easy

Other People Are Reading

Things you need

  • Computer that runs Matlab by MathWorks
  • Two nonlinear equations
  • Region of estimated convergence

Show MoreHide

Instructions

  1. 1

    Rewrite your equations in the form F(X)=0. When typing the equations into Matlab, don't include the "=0" portion, only the expression to the left of the equals sign.

  2. 2

    In a new .m file, type the lines "function F=myfun(x)" and "F=[(your first equation);(your second equation)];" without quotation marks. Save this function as "myfun.m" within your Matlab path.

  3. 3

    On the editor screen, type "x0=[min;max];" where min and max are the minimum and maximum x values of your region of estimated convergence. On the next line, type "options=optimset('Display','iter');" to see the output from the iterations. All commands should be entered without double quotation marks, but single quote marks within the body of the command should remain.

  4. 4

    To run the algorithm, type "[x,fval] = fsolve(@myfun,x0,LargeScale,'off', NonlEqnAlgorithm, 'gn')" without quotation marks and press enter. The command options for LargeScale and NonlEqnAlgorithm specifiy the procedure for Gauss Newton Method. The answer will display on the screen.

Tips and warnings

  • Add semicolons to the end of lines if you do not want to see the output. Forgetting semicolons and displaying output could clog the editor screen.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.