I need to program this in MATLAB and need help with the coding! The table gives
ID: 3553726 • Letter: I
Question
I need to program this in MATLAB and need help with the coding!
The table gives the population of the United States, in millions, for the years 1900-1990:
Year 1900 1910 1920 1930 1940 1950 1960 1970 1980 1990
Population 76 92 106 123 131 150 179 203 227 250
(a) Fit an exponential model using 1900 and 1910 (only) to predict the population in 1990.
(b) Fit an exponential model using 1970 and 1980 (only) to predict the population in 1990.
(c) Fit an exponential model to the entire set of data. Plot the data points and the model on the same graph.
Explanation / Answer
year = [1900 1910 1920 1930 1940 1950 1960 1970 1980 1990];
pop = [76 92 106 123 131 150 179 203 227 250];
%Part a
y=[1900 1910];
p=[76 92];
f1=fit(y,p,'exp1');
p1=f1(1990)
%Part a
y=[1970 1980];
p=[203 227];
f2=fit(y,p,'exp1');
p2=f2(1990)
%Part c
f=fit(year,pop,'exp1')
p3=f3(1990)