我有一个时间序列速度的矢量。例如:
u=[100,120,150,115,130,115,105,103,108,132,135,121]
现在我需要计算Δu,然后绘制一个散点图。 如下图所示。 我该怎么办?
答案 0 :(得分:1)
import numpy as np
import matplotlib.pyplot as plt
u = np.array([100,120,150,115,130,115,105,103,108,132,135,121])
du = u[1:] - u[:-1] # the difference between the current and the prior velocity
plt.scatter(u[1:],du)
plt.show()
答案 1 :(得分:0)
假设Δu = u[i] - u[i-1]
,显然您应该对u[1:]
使用此公式。
因此,只需使用以下代码行:
from numpy import array
import matplotlib.pyplot as plt
u = aray(u)
del_u = u[1:] - u[:-1] # This line let you use that formula for all numbers in array except first one.
plt.scatter(u[1:], del_u)
plt.show()