Matlab拟合多项式代码

x=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y=[1.2, 3, 4, 4, 5, 4.7, 5, 5.2, 6, 7.2]
p2=polyfit(x,y,2)
p3=polyfit(x,y,3)
y2=polyval(p2,x)
y3=polyval(p3,x)
hold on
plot(x,y2,"r")
plot(x,y3,"b")
plot(x,y,"*")

posted @ 2019-08-23 12:54  朵朵奇fa  阅读(1017)  评论(0编辑  收藏  举报