如何随着时间的流逝绘制信号的积分? [英] How to plot the integral of a signal as time goes by?

查看:112
本文介绍了如何随着时间的流逝绘制信号的积分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与时间有关的信号.

I have a time-dependent signal.

我希望绘制其随时间的积分,其中时间为x轴,积分值为y轴.

I wish to plot its integration over time with time being x-axis and integration value being y-axis.

是否有 Python方式?

更具体地说:

我有一个时间数组time和一个信号数组signal.它们具有相同的尺寸.

I have a time array, time, and a signal array, signal. They are of same dimension.

我需要将signal上的signalscipy.integrate.trapz()集成在一起.

I need to integrate signal over time with scipy.integrate.trapz().

我希望没有得到最终的积分,而是希望随着时间的流逝而改变积分.

Instead of getting the final integral, I wish to see the integral varying as time passes.

推荐答案

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

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

它计算包含累积积分值的数组.

It computes an array containing the cumulative integral values.

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

这篇关于如何随着时间的流逝绘制信号的积分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆