Code covered by the BSD License  

Highlights from
2D polynomial fitting with SVD

4.0

4.0 | 1 rating Rate this file 23 Downloads (last 30 days) File Size: 2.47 KB File ID: #31636

2D polynomial fitting with SVD

by Richard Whitehead

 

01 Jun 2011 (Updated 14 Jul 2011)

Fits a polynomial f(x,y) to best fit the data points z using SVD.

| Watch this File

File Information
Description

Use coeffs = fit2dPolySVD(x, y, z, order) to fit a polynomial of x and y so that it provides a best fit to the data z.
Uses SVD which is robust even if the data is degenerate. Will always produce a least-squares best fit to the data even if the data is overspecified or underspecified.
x, y, z are column vectors specifying the points to be fitted.
The three vectors must be the same length.
Order is the order of the polynomial to fit.
Coeffs returns the coefficients of the polynomial. These are in increasing power of y for each increasing power of x, e.g. for order 2:
zbar = coeffs(1) + coeffs(2).*y + coeffs(3).*y^2 + coeffs(4).*x + coeffs(5).*x.*y + coeffs(6).*x^2

Use eval2dPoly(x,y,coeffs) to evaluate the polynomial at any (x,y) points.

If the data is underspecified then the LOWER order coefficients will come out as zero, the solution being a fit using higher orders; use a lower order fit for a more obvious solution in this case.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
2D Weighted Polynomial Fitting and Evaluation

MATLAB release MATLAB 7.12 (2011a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
09 Aug 2011 Ben Abbott  
19 Oct 2011 milad babaei

would somebody plz explain me on that those script algorithm??how does code work (does the least square )???

Please login to add a comment or rating.
Updates
02 Jun 2011

Corrected typos in description

04 Jun 2011

Scaling ignored negative values

01 Jul 2011

Fixed typo in error reporting lines

14 Jul 2011

Minor change to description

Tag Activity for this File
Tag Applied By Date/Time
2d Richard Whitehead 01 Jun 2011 15:48:36
fitting evaluation92 Richard Whitehead 01 Jun 2011 15:48:36
polynomial Richard Whitehead 01 Jun 2011 15:48:36
fitting evaluation Richard Whitehead 02 Jun 2011 16:08:35
2d Wu 02 Jun 2011 23:54:52
2d rahul upneja 03 Sep 2011 04:38:43

Contact us at files@mathworks.com