When integrating acceleration do you need to convert velocity?

16 次查看(过去 30 天)
I am using data from class that is wave data from a boat.
I am taking the accleration data and demeaning it, filtering it, then using cumtrapz twice to get to displacement. Here is my code for one of the axies:
low_x = low_x - mean(low_x);
[B,A] = butter(8,(5/250));
low_xF = filter(B,A,low_x);
vel_x = (386.09) * cumtrapz(.002,low_xF);
vel_x = vel_x - mean(vel_x);
dis_x = cumtrapz(.002,vel_x);
dis_x = dis_x - mean(dis_x);
My output for displacement is saying my boat is going in the air by 1000 inches with only .04gs. I was wondering if I am doing some type of conversion incorrectly. Any help would be appericated.
  4 个评论
John D'Errico
John D'Errico 2024-5-8
编辑:John D'Errico 2024-5-8
Anyway, your fundamental problem lies in what I'll call the initial condition, and also subtracting off the mean of both velocity and acceleration. I'm not sure why you decided to do that. But you should undertand what a constant of integration does for you.
Think of it as an initial condition here. Everything is relative to where you started. When you compute velocity, you need to know how fast you were initially moving. Otherwise you can only know the CHANGE in velocity. The same thing applies to position, versus displacememt. If you don't specify the initial position, then integrating velocity tells you only how far you have moved. It cannot say where you moved to.
All of this is exacerbated by the mean subtraction you did to both velocity and displacement.
For example, suppose I gave you an acceleration profile with time of
A = [1 2 3 4 5];
If we just integrate using cumtrapz, do you see that the first velocity in the vector is ZERO?
V = cumtrapz(A)
V = 1x5
0 1.5000 4.0000 7.5000 12.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
This is because I did not use the implicit constant of integration, which cumtrapz assumes to be just zero. So, if we were moving at an initial velocity of +1 velocity units, then coupled with the given acceleration profile, our velocity over time will look like this:
V0 = 1;
V = cumtrapz(A) + V0
V = 1x5
1.0000 2.5000 5.0000 8.5000 13.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
However, the one thing I don't want to do is subtract off the mean here. That makes no sense at all in this context.
V - mean(V)
ans = 1x5
-5.0000 -3.5000 -1.0000 2.5000 7.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
You can see in this example, if I subtract off the mean, does that imply my initial velocity was -5? Why would that be so?
Anyway, do the same thing for position. Again, we need to know where we started, before we can compute where we ended. Otherwise, all we can learn is how far we moved, thus relative to our starting point.
Sam Chak
Sam Chak 2024-5-8
@Blake: I am using data from class that is wave data from a boat.
If your teacher has taught you how to derive the Equations of Motion of the boat based on the principles of physics, could you provide the mathematical model? This will allow you to compare the predictions from the model with the measured data from the accelerometer sensor.

请先登录,再进行评论。

回答(1 个)

John D'Errico
John D'Errico 2024-5-7
编辑:John D'Errico 2024-5-8
When you keep on subtracting off the mean, you do strange things to the result. But you need to consider what a constant of integration means in this context. If it helps, you can also think about what the initial conditions do for you, when solving an ODE.
For example, suppose your acceleration is a simple sine wave.
t = 0:100;
a_t = sin(t/10);
plot(t,a_t)
There is no need to filter this of course, as there is no source of noise present. Now, suppose we integrate acceleration? The integral of acceleration would have a constant of integration in the result. We tend to forget about these things of course. But that constant of integration is hugely important SOME of the time.
The point is, we need to know what the initial velocity was. Is your object moving at the beginning? If so, then you know V0. For kicks here, I'll postulate that V0, the initial velocity is 1. If we do not do that, what does cumtrapz do? It sets the first point of the integral to ZERO. Effectively, it presumes the initial velocity is zero. If you have some other initial value, then you need to put it back in.
V0 = 1;
V_t = V0 + cumtrapz(t,a_t);
Similarly, if we integrate velocity to get position, we need to know the initial position of the object. (We can integrate velocity to get DISPLACEMENT without specifying an initial position, and that will implicitly assume the initial position was at x==0.)
X0 = 0;
X_t = X0 + cumtrapz(t,V_t);
plot(t,X_t)
We can differentiate this curve twice, to get back to acceleration.
dt = t(2) - t(1);
ahat = gradient(gradient(X_t))/dt^2;
plot(t,a_t,'r-',t,ahat,'go')
As you can see, we recovered the acceleration curve. WHEW! (Got lucky again!)
Now, what did you do wrong? I would suggest you need to use those initial conditions for velocity and position. When you keep on subtracting off those means, things get screwed up if you are not careful. (I honestly don't know why you were subtracting off the mean, and you did it for both velocity and displacement.)
  2 个评论
Blake
Blake 2024-5-8
I am unsure as well. This is the way my teacher is showing me how to do this. From what I understand the reason we are subtracting by the mean each time is to center the waves being plotted on 0.
Torsten
Torsten 2024-5-8
编辑:Torsten 2024-5-8
v(t) = v(0) + integral_{u=0}^{u=t} acceleration(u) du
x(t) = x(0) + integral_{u=0}^{u=t} v(u) du =
x(0) + integral_{u=0}^{u=t} {v(0) + integral_{u'=0}^{u'=u} acceleration(u') du'} du =
x(0) + v(0)*t + integral_{u=0}^{u=t} {integral_{u'=0}^{u'=u} acceleration(u') du'} du
As you can see, the initial values for x and v at t=0 have to be taken into account when computing velocity and position from acceleration.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Vibration Analysis 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by