# How to calculate displacement from acceleration data?

조회 수: 51(최근 30일)
답변: John D'Errico 9 Oct 2019
I have field vibration (acceleration) data that was collected at a sample frequency of 5k Hz. I would like to get instantaneous displacement for each acceration sample. I understand that in physics you would typically define your kinematic equation for acceleration, take the double integral, and input your time = t for when you are trying to calculate your instantaneous displacement.
Since I have messy field data that is a collection of various spectral energy, I can't fit a nice equation to my time history waveform. What is the best way to accomplish my above goal using MATLAB functions?
Please forgive me for forgetting much of my Algebra and Calculus knowledge...

#### 댓글 수: 2

Daniel M 9 Oct 2019
What does the data look like after you integrate it twice?
Well, part of my reason for asking the question was because I was't sure which functions to use. The standard "integral" function requires that you define the function you would like to be integration and I am unable to mathematically define a function from my field data (curve fitting doesn't appear to be an option).
I was able to use the trapz function to integrate (twice) across several samples (e.g. Data(1:5:end, or across 5 samples) and the value appeared to be what I would expect for displacement. I thought there was a way to get instantaneous displacement without curvefitting your acceleration function and taking an indefinite integral, but I have convinced myself otherwise.

### 채택된 답변

John D'Errico 9 Oct 2019
You already know how to use trapz. Just use it twice. However, you mention instantaneous displacement, and the problem with trapz is it gives you an integral over the entire range.
So if you look at the help for trapz, you will see at the bottom, the name cumtrapz.
Cumtrapz gives you the integral cumulatively up to that point. I think this is what you are looking to find. Again, just use cumtrapz twice. The first call gives you velocity. The second call is dosplacement.
In general, if you don't know how to do something in MATLAB, then use tools like help, doc, lookfor. Check the links at the bottom of the help, as they may point you to something good. For example, if you tried this:
lookfor integration
then it would have mentioned cumtrapz as a possible utility of interest.