24小时热门版块排行榜    

查看: 1172  |  回复: 7
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

miracleyin

金虫 (小有名气)

[求助] matlab曲线拟合的一个小问题

我的程序如下:
x=[ 20  30  40  50  60  70  80  90 100];
y=[347 404 420 429 436 455 486 502 436];
[p,s] = polyfit(x,y,8)
xi=linspace(x(1),x(end),1000);
f=polyval(p,xi);
plot(x,y,'ko-',xi,f,'-')
k=polyval(p,x);

可得到的结果为:
p =

  1.0e+003 *

   -0.0000    0.0000   -0.0000    0.0000   -0.0000    0.0009   -0.0248    0.3813   -2.1230


s =

        R: [9x9 double]
       df: 0
    normr: 3.3939e-010


实在不理解这其中p怎么是这样的。我要的这八项多项式的系数的。
回复此楼
keepmoving
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

baby_wolf

新虫 (初入文坛)


dbb627(金币+1): 欢迎交流 2011-11-28 20:10:46
引用回帖:
7楼: Originally posted by baby_wolf at 2011-11-28 02:48:47:
可以通过这样一条命令来格式显示。

sprintf('%.2f    ',p)

表示将p矩阵的每个元素以两位小数形式输出
8楼2011-11-28 02:49:52
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 8 个回答

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

miracleyin(金币+2): 2011-11-26 12:34:53
x=[ 20  30  40  50  60  70  80  90 100];
y=[347 404 420 429 436 455 486 502 436];
[p,s] = polyfit(x,y,8)
fx=poly2sym(p)%这个可以表示成多项式格式
xi=linspace(x(1),x(end),1000);
f=polyval(p,xi);
plot(x,y,'ko-',xi,f,'-')
k=polyval(p,x);

p =

  1.0e+003 *

   -0.0000    0.0000   -0.0000    0.0000   -0.0000    0.0009   -0.0248    0.3813   -2.1230
这个就是八阶多项式系数 一共九项(x---x^8+常数项)
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
2楼2011-11-26 11:34:55
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

miracleyin

金虫 (小有名气)

引用回帖:
2楼: Originally posted by dbb627 at 2011-11-26 11:34:55:
x=[ 20  30  40  50  60  70  80  90 100];
y=[347 404 420 429 436 455 486 502 436];
[p,s] = polyfit(x,y,8)
fx=poly2sym(p)%这个可以表示成多项式格式
xi=linspace(x(1),x(end),1000);
f=polyval(p,xi); ...

那1.0e+003 *  是表示什么意思呢?
keepmoving
3楼2011-11-26 11:52:28
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

表示的就是 1000×
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
4楼2011-11-26 12:18:59
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见