||
pro parabola
x=[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0]
y=[8.8,21.6,32.4,51.2,72.0,94.8,125.6,156.4]
result=poly_fit(x,y,2);拟合抛物线
x1=max(x)*randomu(10,1000)
y1=result[2]*x1^2+result[1]*x1+result[0]
print,'y=',result[2],'x^2+',result[1],'x+',result[0]
set_plot,'PS'
filename='f:parabola.eps'
device,file=filename,/ENCAPSULATED,/COLOR, BITS=8,xsize=xsize,ysize=ysize
plot,x,y,psym=4,symsize=1,xrange=[0,10],yrange=[0,160]
oplot,x1,y1,psym=3,symsize=0.1
device,/CLOSE
END
输出的结果y= 1.82143x^2+ 4.57381x+ 3.32143
画出来的图
带权重的抛物线拟合:Result = POLYFITW(X, Y, Weights,2)
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2025-1-6 16:26
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社