matlab多项式拟合

想用工具箱对这两组数据进行多项式拟合,应该如何操作?
x=2000:1:2013;
y=[17118 17230 17492 17460 17495 17573 17770 19834 23393 23741 24090 24438 24786 25135];

在命令窗口下输入
x=[。。。]
y=[。。。]
cftool
在Curve Fitting Tool界面中,单击Data。。。,选择x Data和y Data,选择Create data set,选择Close
在Curve Fitting Tool界面中,单击Fitting。。。,选择New fit,选择Type of fit,选择Polynomial,选择9th degree polynomial,打勾Center and scale X data项和Immediate apply项,选择Apply
在Results框内,就会出现如下信息
Linear model Poly9:
f(x) = p1*x^9 + p2*x^8 + p3*x^7 + p4*x^6 +
p5*x^5 + p6*x^4 + p7*x^3 + p8*x^2 + p9*x + p10
where x is normalized by mean 2007 and std 4.183
Coefficients (with 95% confidence bounds):
p1 = 1250 (-2623, 5123)
p2 = -1317 (-3803, 1169)
p3 = -7686 (-2.787e+004, 1.25e+004)
p4 = 7016 (-4784, 1.882e+004)
p5 = 1.706e+004 (-1.775e+004, 5.186e+004)
p6 = -1.244e+004 (-2.995e+004, 5083)
p7 = -1.69e+004 (-3.952e+004, 5721)
p8 = 8533 (-214.7, 1.728e+004)
p9 = 9654 (5118, 1.419e+004)
p10 = 1.902e+004 (1.797e+004, 2.007e+004)
Goodness of fit:
SSE: 1.213e+006
R-square: 0.9921
Adjusted R-square: 0.9742
温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-03-16

x=2000:1:2013;
y=[17118 17230 17492 17460 17495 17573 17770 19834 23393 23741 24090 24438 24786 25135];     %输入原始数据

cftool;     %调用曲线拟合工具箱

在x、y处选择已经输入的x向量和y向量,在拟合方式选择多项式(polynomial),并选择几次多项式拟合(degree),这里是用5次多项式拟合的结果:

在左边的results窗口中会显示多项式具体的系数,以及拟合程度。

第2个回答  2014-03-16
x=2000:1:2013;
y=[17118 17230 17492 17460 17495 17573 17770 19834 23393 23741 24090 24438 24786 25135];
n=2;%多项式次数
[p,s,mu]=polyfit(x,y,n) %具体参数意思看MATLAB帮助