作业帮 > 综合 > 作业

matlab 指数拟合问题

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/09/28 09:30:05
matlab 指数拟合问题
下列这组数据是美国1900—2000年人口的近似值(单位:百万).
时间t
1900
1910
1920
1930
1940
1950
1960
1970
1980
1990
2000
人口y
76
92
106
123
132
151
179
203
227
250
281若y与t的经验公式是y=a*e^(bt)试编写程序计算出上式中的a、b
matlab 指数拟合问题
t=[1900
1910
1920
1930
1940
1950
1960
1970
1980
1990
2000];
y=[76
92
106
123
132
151
179
203
227
250
281];
xData = t;
yData = y;
% Set up fittype and options.
ft = fittype( 'exp1' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.StartPoint = [1.69506734646774e-009 0.0129343435595401];
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts )
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, xData, yData );
legend( h, 'y vs. t', 'fit 1', 'Location', 'North' );
% Label axes
xlabel( 't' );
ylabel( 'y' );
grid on
.
运行结果
General model Exp1:
fitresult(x) = a*exp(b*x)
Coefficients (with 95% confidence bounds):
a = 4.668e-009 (-1.321e-009, 1.066e-008)
b = 0.01242 (0.01177, 0.01307)