拟合函数用错了吗?
Warning: Polynomial is badly conditioned. Remove repeated data pointsor try centering and scaling as described in HELP POLYFIT.
运行程序后有这样的提示,是拟合函数用错了吗?
[ 本帖最后由 ChaChing 于 2009-3-21 21:21 编辑 ] 检查LZ的输入点是否有重覆!
回复 沙发 ChaChing 的帖子
可是就算有重复,POLYFIT也可以进行啊回复 楼主 linden 的帖子
将拟合类型修改一下,好像有spline和cubic等等的,我原来也遇到过的,修改之后就好了,你最好给出原始的程序把,便于调试回复 板凳 qingqing5638 的帖子
这个问题说来话长, 而且个人数值分析的东西已经忘了差不多了!简单的说, 楼主所说的警示, 并非重覆点就一定会出现, 仅当其Orthogonal-triangular decomposition(QR)中的1-norm condition number (condest)非常大时才会出现, 当然会如此一般都是重覆点造成矩阵badly conditioned!
而且新旧版警示语是不同的, 楼主用的应该是V6.5附近的版本, 新版已经不是这个警语了! 给个例子
for v6.5
>> x = (0: 0.2: 1)'; y = erf(x); x2=; y2=;
>> p = polyfit(x,y,6)
Warning: Polynomial is not unique; degree >= number of data points.
(Type "warning off MATLAB:polyfit:PolyNotUnique" to suppress this warning.)
> In C:\MATLAB6p5\toolbox\matlab\polyfun\polyfit.m at line 68
p = 0.0030 0 0.1542 -0.4624 0.0215 1.1265 0.0000
>> p2 = polyfit(x2,y2,6)
Warning: Polynomial is badly conditioned. Remove repeated data points
or try centering and scaling as described in HELP POLYFIT.
(Type "warning off MATLAB:polyfit:RepeatedPointsOrRescale" to suppress this warning.)
> In C:\MATLAB6p5\toolbox\matlab\polyfun\polyfit.m at line 75
p2 = -0.5730 1.7279 -1.8041 0.5743 -0.2310 1.1486 0.0000
>> p2 = polyfit(x2,y2,5)
p2 = 0.0090 0.1440 -0.4570 0.0202 1.1266 0.0000
>> p = polyfit(x,y,5)
p = 0.0090 0.1440 -0.4570 0.0202 1.1266 0.0000
for R2006a
>> x = (0: 0.2: 1)'; y = erf(x); x2=; y2=;
>> p = polyfit(x,y,6)
Warning: Polynomial is not unique; degree >= number of data points.
> In polyfit at 72
p = 0.0030 0 0.1542 -0.4624 0.0215 1.1265 -0.0000
>> p2 = polyfit(x2,y2,6)
Warning: Polynomial is badly conditioned. Add points with distinct X
values, reduce the degree of the polynomial, or try centering
and scaling as described in HELP POLYFIT.
> In polyfit at 80
p2 = -0.4050 1.2240 -1.2331 0.2720 -0.1574 1.1421 -0.0000
>> p = polyfit(x,y,5)
p = 0.0090 0.1440 -0.4570 0.0202 1.1266 0.0000
>> p2 = polyfit(x2,y2,5)
p2 = 0.0090 0.1440 -0.4570 0.0202 1.1266 -0.0000
for R2009a
>> p2 = polyfit(x2,y2,6)
Warning: Polynomial is badly conditioned. Add points with distinct X
values, reduce the degree of the polynomial, or try centering
and scaling as described in HELP POLYFIT.
> In polyfit at 80
p2 =
-0.5135 1.5496 -1.6021 0.4673 -0.2050 1.1463 -0.0000
**** other is same R2006a ****
[ 本帖最后由 ChaChing 于 2010-3-21 16:56 编辑 ]
页:
[1]