Mathematics Previous page   Next Page

Polynomial Curve Fitting

polyfit finds the coefficients of a polynomial that fits a set of data in a least-squares sense.

x and y are vectors containing the x and y data to be fitted, and n is the order of the polynomial to return. For example, consider the x-y test data.

A third order polynomial that approximately fits the data is

Compute the values of the polyfit estimate over a finer range, and plot the estimate over the real data values for comparison.

To use these functions in an application example, see the Data Analysis and Statistics chapter.


Previous page  Polynomial Derivatives Partial Fraction Expansion Next page

© 1994-2005 The MathWorks, Inc.