func4p2.m
资源名称:数值分析课程设计.zip [点击查看]
上传用户:zhdd911129
上传日期:2007-05-11
资源大小:722k
文件大小:0k
源码类别:
matlab例程
开发平台:
Matlab
- %func4p2.m,求拟合多项式
- x=linspace(1,12,12)
- y=[12,234,34,-1,34,2,5,23,34,9,45,23]
- p=polyfit(x,y,6)
- xx=linspace(1,12,100)
- yy=polyval(p,xx)
- plot(xx,yy,'-')
- f=polyval(p,x)
- disp(abs(norm(y,inf)-norm(f,inf)))
- %如用二次多项式拟合,the residue is (defined by infinite norm on those vector):135.5165,相当高。
- %如提高为用六次多项式拟合,residue= 40.7265,比较精确;十次:residue=0.1571,相当低
- %can also see the figure