版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/NockinOnHeavensDoor/article/details/83385732
numpy.interp
作用:给定1维数据点上做插入。
-
Parameters:
x : 要估计坐标点的x坐标值。xp : x坐标值,
must be increasing if argument period is not specified.
Otherwise, xp is internally sorted after normalizing the periodic boundaries with xp = xp % period.fp : y坐标值,
same length as xp
.right : 对应
x > xp[-1]
时fp
的default is fp[-1].period : x坐标轴的周期,声明忽略左边或者右边的插值。
-
return:
y :The interpolated values, same shape as x.
例子:
x = np.linspace(0, 2*np.pi, 10)
y = np.sin(x)
xvals = np.linspace(0, 2*np.pi, 50)
yinterp = np.interp(xvals, x, y)
import matplotlib.pyplot as plt
plt.plot(x, y, 'o')
plt.plot(xvals, yinterp, '-x')
plt.show()