所以我有这个数据
x
1.0423
2.8249
3.2016
2.0851
1.0299
4.7397
0.4104
0.5285
0.7102
0.8323
3.1048
2.8685
0.2604
4.6560
3.6433
3.6892
0.3170
4.3022
4.6720
4.9220
y
2.0529
-3.0669
-2.3631
-0.7300
1.4354
2.0260
0.5980
0.5296
1.3405
1.7361
-1.5876
-2.7872
1.0788
1.3677
-0.1355
-1.5755
0.7811
-0.8328
-0.0592
2.0927
我尝试使用 cftool 将 8 阶多项式拟合到数据中。
这些是我得到的结果是错误的
Linear model Poly8:
f(x) = p1*x^8 + p2*x^7 + p3*x^6 + p4*x^5 +
p5*x^4 + p6*x^3 + p7*x^2 + p8*x + p9
Coefficients (with 95% confidence bounds):
p1 = -0.05446 (-0.126, 0.01711)
p2 = 1.088 (-0.3839, 2.561)
p3 = -8.762 (-21.23, 3.706)
p4 = 36.2 (-19.89, 92.3)
p5 = -80.85 (-225.3, 63.62)
p6 = 94.32 (-119.9, 308.6)
p7 = -52.21 (-227.5, 123.1)
p8 = 12.21 (-59.01, 83.42)
p9 = -0.05814 (-10.72, 10.61)
Goodness of fit:
SSE: 4.083
R-square: 0.9225
Adjusted R-square: 0.8661
RMSE: 0.6092
这是拟合的 cftool 图,看起来不错
这就是绘制系数的实际样子。
绘制系数的代码:
xx = 0:1/100:5;
yy = -0.05446*xx.^8 +1.088*xx.^7 -8.762*xx.^6 +36.2*xx.^5 -80.85*xx.^4 +94.32*xx.^3 -52.21*xx.^2 +12.21*xx -0.05814;
plot(xx,yy)
有谁知道发生了什么以及如何获得 cftool 产生的绘图的正确系数?