作业帮 > 数学 > 作业

帮我求下用最小二乘法拟合一个多项式

来源:学生作业帮 编辑:作业帮 分类:数学作业 时间:2024/05/13 05:03:03
帮我求下用最小二乘法拟合一个多项式
我自己用MATLAB拟合一个5次多项式的系数如:y=a+bx+cx^2+dx^3+ex^4+fx^5,无论用最小二乘法命令lspoly()还是ployfit()算的结果都有警告,我自己检查了一下我算的结果不对;
如题:>> x=[1000 1250 1500 1750 2000 2250 2500 2750 3000];
>> y=[300 312 310 303 298 292 288 280 272];
>> f=lspoly(x,y,5)
Warning:Matrix is close to singular or badly scaled.
Results may be inaccurate.RCOND = 3.779465e-040.
> In lspoly at 11
c =
0.0000
-0.0000
0.0000
-0.0018
1.8802
-431.8485
帮我用MATLAB把这个系数拟合出来吧,我算的这个结果应该是错的.本人现在百度还没什么财富,以后有机会再加啊,急用啊
Warnings during fitting:
Equation is badly conditioned.Remove repeated data points
or try centering and scaling.
这是因为你的数据点不好.
此外,你用的拟合函数的阶数很高……如果换成二阶就可以使用polyfit()了.
下面是用curve fitting tool的拟合结果:
Linear model Poly5:
f(x) = p1*x^5 + p2*x^4 + p3*x^3 + p4*x^2 + p5*x + p6
Coefficients (with 95% confidence bounds):
p1 = 1.739e-14 (2.242e-15,3.255e-14)
p2 = -1.951e-10 (-3.468e-10,-4.337e-11)
p3 = 8.54e-07 (2.646e-07,1.443e-06)
p4 = -0.001825 (-0.002932,-0.0007169)
p5 = 1.88 (0.8761,2.884)
p6 = -431.8 (-781.9,-81.76)
Goodness of fit:
SSE:1.349
R-square:0.9991
Adjusted R-square:0.9975
RMSE:0.6706