Javier Javier - 4 months ago 30
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?


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]