各位大神走过路过,帮帮小弟。
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( '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