NXP

numpy:interp插值

2019-07-12 12:28发布

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()