I’m trying to get a displacement from a velocity.
For a constant velocity, the formula is:
x_h = x_c + V*t
Where x_c
is an initial value, V
is the velocity magnitude and t
a time vector.
I now have a velocity u
that is as below. Theta is an azimuthal position, it is essentially related to time.
It starts from an undisturbed value (equal to V
) then drops and recovers twice and at the end of the period (theta = 360 deg) it goes back to the undisturbed value.
To compute the displacement, I do:
x_h = x_c + cumtrapz(u,t)
Below the displacements for constant velocity (formula with no integration) and non-constant velocity are plotted:
The issue is that, as you can see, cumtrapz drifts more and more away from the undisturbed value as time goes by.
Consider that there’s also another period preceding theta = 0 deg, so x_h
is not starting at the undisturbed value at theta=0 deg, although it should. This would only happen if there was no drift introduced by cumtrapz.
If I try to do:
x_h(t) = x_h(t-1) + u(t-1) dt(t-1)
I get basically the same.
I checked that x_h(t) - x_h(t-1)
behaves as the above-plotted u
, which is the case, so both the integration formulas are correct.
However, I get the above-mentioned drift issue.
Please note: u
velocity is supposed to behave like that, its trend is not due to some sort of bias or noise in the data.
How can I fix this, preferably keeping x_h(t) - x_h(t-1)
behaving as the u velocity?
Thanks for your help.