The results I am getting are not plausible, they are way too high. I think the way I am calculating the acceleration is wrong, but I don't know how exactly. Can somebody help me?
Thank you for your input. I have tinkered a little more and found the solution:
I didn't convert kph into m/s. The factor is 1 / 3.6 .
The time in between measurements of 10 ms is too short. If you space the measurements out more to, say, 100 ms the results are more stable.
I don't take the initial velocity into account. My first measurement is wrong as a result but all the others are correct. That is good enough for my application.
For point 2, time is irrelevant - it's quite literally not in the equation . If your V and S values are correct then your interval for checking doesn't matter. If it's not working at 10 ms then you should really determine why - is the S or V measurement not possible?
In terms of the initial velocity, it shouldn't matter if it's your first measurement or your last, it does need to be in there (unless it's zero). Either all your measurements should be correct, or you should be concerned that they are all incorrect.
There must be distance in their code somewhere to get the velocity. The unkown is what "measure()" does. In their acceleration they are assuming a fixed 10ms despite the code allowing for a greater than that (also, shouldn't that check be ">=" 10 for it to be every 10ms?) which sent me off on my tangent of eliminating the time side of things. That would give them an accurate acceleration for their readings, without being influenced by other timings (if that makes sense, for example what if "measure()" takes 6ms to initialise before getting the velocity reading?).
In any case I think the OP has happily carried on at this point
I think you've mixed up A(cceleration) and V(elocity). As far as I'm aware to get V without knowing S (displacement) you need to know A. Given the question is about finding A I'm assuming they don't already know it.
a = (v - u)/t ; classic definition of acceleration.
acceleration is change in velocity over time , not distance.
acceleration units metres per second per second.
looks like you want to replace v[n] with a value and then sum all the values in the array and divide by the number of values
corrected
here's a simpler approach using a leaky integration to average the velocity. no need to average the acceleration.
produces the following results on my laptop using random values