python - 如何随着时间的推移绘制信号的积分?

标签 python numpy matplotlib scipy

我有一个随时间变化的信号。

我想绘制它随时间的积分,时间是 x 轴,积分值是 y 轴。

是否有任何 Python 方式可以做到这一点?

更具体地说:

我有一个时间数组 time 和一个信号数组 signal。它们具有相同的维度。

我需要在 time 上将 signalscipy.integrate.trapz() 集成。

我不想得到最终的积分,而是希望看到积分随着时间的推移而变化。

最佳答案

尝试使用 scipy.integrate.cumtrapz() 代替:

plt.plot(time[:-1], scipy.integrate.cumtrapz(signal, x=time))
plt.show()

它计算一个包含累积积分值的数组。

http://docs.scipy.org/doc/scipy-0.10.1/reference/generated/scipy.integrate.trapz.html

关于python - 如何随着时间的推移绘制信号的积分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18245975/

相关文章:

python - 未绑定(bind)本地错误: local variable 'y' referenced before assignment in Pandas

python - pandas/numpy int64 中意外的 32 位整数溢出(python 3.6)

python - 如何将for循环的结果存储为数组?

python - 在 Pandas 中旋转一系列评级列

Python matplotlib 顺时针饼图

python - 发送一个 python 修饰方法作为函数参数

Python 二进制转十六进制

python - 随机数生成器的性能结果相互矛盾

python - 在matplotlib中将多个图形保存到一个pdf文件

python - 如果 yticks 太多,Seaborn 会自动隐藏 yticks