声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 5791|回复: 5

[综合讨论] 拟合函数用错了吗?

[复制链接]
发表于 2009-3-21 11:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
Warning: Polynomial is badly conditioned. Remove repeated data points
         or try centering and scaling as described in HELP POLYFIT.
运行程序后有这样的提示,是拟合函数用错了吗?

[ 本帖最后由 ChaChing 于 2009-3-21 21:21 编辑 ]
回复
分享到:

使用道具 举报

发表于 2009-3-21 20:47 | 显示全部楼层
检查LZ的输入点是否有重覆!
发表于 2009-4-11 13:05 | 显示全部楼层

回复 沙发 ChaChing 的帖子

可是就算有重复,POLYFIT也可以进行啊
发表于 2009-4-11 19:40 | 显示全部楼层

回复 楼主 linden 的帖子

将拟合类型修改一下,好像有spline和cubic等等的,我原来也遇到过的,修改之后就好了,你最好给出原始的程序把,便于调试
发表于 2009-4-11 23:00 | 显示全部楼层

回复 板凳 qingqing5638 的帖子

这个问题说来话长, 而且个人数值分析的东西已经忘了差不多了!
简单的说, 楼主所说的警示, 并非重覆点就一定会出现, 仅当其Orthogonal-triangular decomposition(QR)中的1-norm condition number (condest)非常大时才会出现, 当然会如此一般都是重覆点造成矩阵badly conditioned!
而且新旧版警示语是不同的, 楼主用的应该是V6.5附近的版本, 新版已经不是这个警语了!

评分

1

查看全部评分

发表于 2009-4-11 23:13 | 显示全部楼层
给个例子
for v6.5
>> x = (0: 0.2: 1)'; y = erf(x); x2=[x;x]; y2=[y;y];
>> 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=[x;x]; y2=[y;y];
>> 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

查看全部评分

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-6-28 15:04 , Processed in 0.069305 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表