matlab曲线拟合函数

各位大神走过路过,帮帮小弟。
x=[1953 1964 1982 1989 2000 2010];
y=[6.02e+08 7.23e+08 1.03e+09 1.16e+09 1.24e+09 1.33e+09];
求其拟合函数,要有原程序。再次感谢各位了
大神 能否不用多项式模型 这个误差太大

x=[1953 1964 1982 1989 2000 2010];
y=[6.02e+08 7.23e+08 1.03e+09 1.16e+09 1.24e+09 1.33e+09];

[xData, yData] = prepareCurveData( x, y );

% Set up fittype and options.
ft = fittype( 'poly1' );
opts = fitoptions( ft );
opts.Lower = [-Inf -Inf];
opts.Upper = [Inf Inf];

% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );

% Plot fit with data.
figure( 'Name', 'linerFit' );
h = plot( fitresult, xData, yData );
legend( h, 'y vs. x', 'linerFit', 'Location', 'NorthEast' );
% Label axes
xlabel( 'x' );
ylabel( 'y' );
grid on
结果:
Linear model Poly1:
ans(x) = p1*x + p2
Coefficients (with 95% confidence bounds):
p1 = 1.344e+07 (1.075e+07, 1.613e+07)
p2 = -2.563e+10 (-3.097e+10, -2.03e+10)
说明:我这里用的是最小二乘的一阶拟合,如果是二阶可以将poly1改为poly2,以此类推poly3等追问

用指数函数的那个行吗 谢谢你了

追答

高斯函数拟合,指数的
[xData, yData] = prepareCurveData( x, y );

% Set up fittype and options.
ft = fittype( 'gauss1' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = [-Inf -Inf 0];
opts.StartPoint = [1330000000 2010 27.2886751671404];
opts.Upper = [Inf Inf Inf];

% 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. x', 'untitled fit 1', 'Location', 'NorthEast' );
% Label axes
xlabel( 'x' );
ylabel( 'y' );
grid on

结果:
General model Gauss1:
f(x) = a1*exp(-((x-b1)/c1)^2)
Coefficients (with 95% confidence bounds):
a1 = 1.35e+09 (1.19e+09, 1.51e+09)
b1 = 2019 (1998, 2041)
c1 = 72.42 (50.31, 94.52)

Goodness of fit:
SSE: 2.306e+15
R-square: 0.9946
Adjusted R-square: 0.991
RMSE: 2.772e+07

温馨提示:答案为网友推荐,仅供参考