Double Integration of Numeric Data - Acceleration -> Displacement
14 views (last 30 days)
Show older comments
I have a data set of accelerlation data points over 10ms, sampled at 1MHz. I am trying to take this acceleration data and convert it to displacement data. I have a referenced graph that is attached that I am trying to get my data to match, but it seems like they did not do a cumtrapz, and only did a point by point integral.
When I tried to use Cumtrapz it seems like, A09 it does not have the return back to -5mm after a 2nd order cumtrapz. I have tried doing a point by point integration (A9(1:end-1)+A9(2:end)) * (dt/2); and this did not bring create the same graph.
I am looking for some insight on what the right function it should be/ the reason after doing a "double integral" these two graphs do not match.
Thank you for the insight.
2 Comments
John D'Errico
on 8 Jan 2025
Edited: John D'Errico
on 8 Jan 2025
I know what a definite integral means. I know what an indefinite integral means. Yet, despite having spent an entire career as a mathematician, I don't know what a definite point by point integral means. If you invent your own jargon, then expect people to be confused.
What do you mean by the vectors in A9.mat and A2.mat? Yes, apparently these are accelerations, based on your comments. at least that is what you seem to think. I might suppose they are taken at some point on a chest, given the figure title. But you might need to contact the source of the data to know the meaning, and where the failure arises.
To answer what is i think your question, is if you use cumtrapz twice on those data, assuming they would be validly measured accelerations taken from a chest cavity, AND they represent a complete beath cycle, then at some point in the cycle, the result should return to roughly the start point. You don't tell us dt, but that is just a scaling.
Could it be that this is only data from a partial breathing cycle? We don't know.
load A2.mat
plot(Datashort1);
Assuming those are accelerations, taken by an accelerometer at a constant (unknown) time step, the first integral would be velocity.
However, if we look at the figure you show, that shows a negative displacement curve. Yet the accelerations start off with a positive acceleration.
So it might be possible the accelerations are sign swapped, where the accelerometer is set to measure a positive acceleration as chest compression. That may make sense, since the figure (y axis) is labeled compression. Hard to be sure. I would check with the source.
Answers (1)
Torsten
on 8 Jan 2025
Edited: Torsten
on 8 Jan 2025
Assuming x(0) = v(0) = 0 in both cases, I get
load("A2.mat")
load("A9.mat")
a2 = Datashort1;
a9 = Datashort21;
figure
plot(0:1e-3:10,[a2,a9])
v2 = cumtrapz(-a2)*1e-3;
v9 = cumtrapz(-a9)*1e-3;
figure
plot(0:1e-3:10,[v2,v9])
x2 = cumtrapz(v2)*1e-3;
x9 = cumtrapz(v9)*1e-3;
figure
plot(0:1e-3:10,[x2,x9]*1e-2)
If v(0) is not equal to 0, things will change remarkably.
It would help if we knew the physical unit of your acceleration data.
8 Comments
Torsten
on 10 Jan 2025
Edited: Torsten
on 10 Jan 2025
In answer to your question the accerleration takes the form of g. But all that will do will change the scaling of the y axis and not affect the shape of the displacement graph.
I only noticed that the unit for g used in your acceleration data is quite strange. If the order of magnitude for the displacement compared to Picture1.jpg should be approximately equal, the unit is mm*10^(-2)/(10^(-3)*s)^2 .
But after running a point by point, which is X+ X+1 that obviously does not even come close to the output of the cumtrapz curves.
You can use a "point-by-point" method to integrate, but then you must add the results - and this is exactly what "cumtrapz" does:
load("A2.mat")
load("A9.mat")
a2 = Datashort1;
a9 = Datashort21;
figure
plot(0:1e-3:10,[a2,a9])
v2(1) = 0;
x2(1) = 0;
for i = 2:numel(a2)
v2(i) = v2(i-1) - 1e-3*(a2(i-1)+a2(i))/2;
x2(i) = x2(i-1) + 1e-3*(v2(i-1)+v2(i))/2;
end
v9(1) = 0;
x9(1) = 0;
for i = 2:numel(a9)
v9(i) = v9(i-1) - 1e-3*(a9(i-1)+a9(i))/2;
x9(i) = x9(i-1) + 1e-3*(v9(i-1)+v9(i))/2;
end
figure
plot(0:1e-3:10,[x2;x9]*1e-2)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!