resampled time using scipy.signal.resample

[亡魂溺海] 提交于 2019-11-30 20:10:11

Even when you give the x coordinates (which corresponds to the t argument), resample assumes that the sampling is uniform.

Consider using one of the univariate interpolators in scipy.interpolate.

For example, this script:

import numpy as np
from scipy import interpolate
import matplotlib.pyplot as plt

x = np.array([0,1,2,3,4,5,6,6.5,7,7.5,8,8.5,9])
y = np.cos(-x**2/4.0)

f = interpolate.interp1d(x, y)

num = 50
xx = np.linspace(x[0], x[-1], num)
yy = f(xx)

plt.plot(x,y, 'bo-')
plt.plot(xx,yy, 'g.-')
plt.show()

generates this plot:

Check the docstring of interp1d for options to control the interpolation, and also check out the other interpolation classes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!