numpy:interp插值

版权声明:本文为博主原创文章,未经博主允许不得转载。 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()

猜你喜欢

转载自blog.csdn.net/NockinOnHeavensDoor/article/details/83385732
今日推荐