更新时间:2023-02-26 17:00:01
Even when you give the x
coordinates (which corresponds to the t
argument), resample
assumes that the sampling is uniform.
请考虑在 scipy.interpolate
中使用单变量插值器之一.
Consider using one of the univariate interpolators in scipy.interpolate
.
例如,此脚本:
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()
生成此图:
检查 interp1d
的文档字符串>用于控制插值的选项,并查看其他插值类.
Check the docstring of interp1d
for options to control the interpolation, and also check out the other interpolation classes.