Javier Javier - 1 year ago 69
Python Question

Velocity from array of acceleration samples in Python

I've got this pretty big list of acceleration samples (about 300k) which I plot with matplotlib. My goal is to also plot the velocity and get its maximum value.

Is there a way to integrate the acceleration list in order to get a velocity list?

Answer Source

So. This is the way I'm doing the job assuming a sampling rate of 10 Hz.

acceleration = [1, 2, 3, 4, 5, 6, 7, 8, 9]
velocity = [0]
time = 0.1
for acc in acceleration:
    velocity.append(velocity[-1] + acc * time)
del velocity[0]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download