Can we predict the US population in the year 2010?
Fitting the Data
Add supporting information to the text, including equations, images, and hyperlinks.
Let's try fitting the data with polynomials. We'll use the MATLAB polyfit function to get the
coefficients.
The fit equations are:
y = ax + b
linear
y = ax 2 + bx + c
quadratic
y = ax 3 + bx 2 + cx + d .
cubic
x = (years-1900)/50;
coef1 = polyfit(x,pop,1)
coef1 = 1×2
98.9924
66.1296
coef2 = polyfit(x,pop,2)
coef2 = 1×3
Introduction to the Live Editor
19-61
Fitting the Data
Add supporting information to the text, including equations, images, and hyperlinks.
Let's try fitting the data with polynomials. We'll use the MATLAB polyfit function to get the
coefficients.
The fit equations are:
y = ax + b
linear
y = ax 2 + bx + c
quadratic
y = ax 3 + bx 2 + cx + d .
cubic
x = (years-1900)/50;
coef1 = polyfit(x,pop,1)
coef1 = 1×2
98.9924
66.1296
coef2 = polyfit(x,pop,2)
coef2 = 1×3
Introduction to the Live Editor
19-61
