标签:
杂谈 |
xdata=[1500 2000
2500 3000 3500 4000 4500 5000 5500];
ydata=[78.59 83.04 84.11 86.63 87.61 84.87 84.67 82.50 80.54]; x0=[1 2 1 1]; x=lsqcurvefit(@myfun,x0,xdata,ydata); plot(xdata,ydata,'*'); holdon; a=polyfit(xdata,ydata,3); forc=1500:1:5500; b=polyval(a,c); plot(c,b,'k'); holdon; end; 运行结果 a = 0.0000 x = 0.0694 x polyfit 可以用help polyfit P = POLYFIT(X,Y,N) finds the coefficients of a polynomial P(X) of degree N that fits the data Y best in a least-squares sense. 既然Polyfit 当数据点较多时,如何确定拟合多项式的次数,常用方法是逐次增加拟合多项式的次数,并计算平方误差,以寻求效果较好的拟合多项式。 此日志来自QQ邮箱!方便快捷写Qzone的新方式,详情请进>> |