永发信息网

下面是一个简单的MATLAB编程, 编译时出现了下面的Warning,哪位高手能看看怎么修改可以消除Warnning

答案:2  悬赏:70  手机版
解决时间 2021-04-30 06:14
  • 提问者网友:wodetian
  • 2021-04-29 19:41

主要是是对一些数据进行拟合,并画出曲线。程序如下: t=1:9;
x=[12.51,13.54,15.60,15.92,20.64,24.53,30.24,50.00,36.34];
y=[9.87,20.54,32.51,40.50,48.31,64.51,72.22,85.98,89.77];
a8=polyfit(t,x,8);
b8=polyfit(t,y,8);
ti=linspace(1,9);
xi8=polyval(a8,ti);
yi8=polyval(b8,ti);
plot(t,x,'o',ti,xi8,'k')
hold on;
plot(t,y,'*',ti,yi8,'k')

Warning: Polynomial is badly conditioned. Remove repeated data points
or try centering and scaling as described in HELP POLYFIT.
> In polyfit at 79
Warning: Polynomial is badly conditioned. Remove repeated data points
or try centering and scaling as described in HELP POLYFIT.
> In polyfit at 79

可以画出图形如上:为什么可以作图,他还出现警告了,哪位高手知道怎样修改,使它变得更加完美,没有Warning.

最佳答案
  • 五星知识达人网友:山有枢
  • 2021-04-29 20:38

t=1:9;
x=[12.51,13.54,15.60,15.92,20.64,24.53,30.24,50.00,36.34];
y=[9.87,20.54,32.51,40.50,48.31,64.51,72.22,85.98,89.77];
a8=polyfit(t,x,7);
b8=polyfit(t,y,7);
ti=linspace(1,9);
xi8=polyval(a8,ti);
yi8=polyval(b8,ti);
plot(t,x,'o',ti,xi8,'k')
hold on;
plot(t,y,'*',ti,yi8,'k')


警告是告诉你,你不需要用8价函数就可以完美拟合,所以,降到7价就不报错了

全部回答
  • 1楼网友:不如潦草
  • 2021-04-29 21:04

在Command Window中输入>>help polyfit 试着按照他上边的提示位置看看做相应的修改吧!

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯