How to Do Polynomial Curve Fitting in Matlab

Polynomial curve fitting is a common task for data analysts in many fields of science, engineering and social science.  The standard method to fit a curve to data is to use the least squares method.  In this method, the coefficients of the estimated polynomial are determined by minimizing the squares of errors between the data points and fitted curve.  This method is used to determine the relationship between an independent and dependent variable.  The common term regression line is used for a first-degree polynomial.  Matlab has a simple function called polyfit that allows an analyst to use the least squares method.  In this post, a simple example of polyfit is presented to determine the relationship between two variables in a noisy environment.

Continue reading