You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How I can produce the integration of digital signal data without knowing the function?
48 views (last 30 days)
Show older comments
Hello all,
I have 512 acceleration data points. I want to integrate the data points to get the velocity and then the displacement data points by using Trapezium and Sympson's rules.
Example of my data points: x = [0 0.002 0.0039 0.0059 0.0078 0.0098 0.0117]; time(s) y = [-0.5570 0.1310 0.4010 0.0722 -0.5210 -0.8090 -0.7230]; acceleration (m/s2)
The problems happened when I looked around MATLAB code needs a function. By I dont.
Please advice.
Thank you for your time.
Regards, SMY
Accepted Answer
Star Strider
on 3 Jun 2016
Use the cumtrapz function with your vector. It does not need a function.
15 Comments
SMY
on 3 Jun 2016
Thank you so much! The trapezium integration was working now. But how about the Simpson's rule? Did you have any idea on that?
Star Strider
on 3 Jun 2016
My pleasure!
You would have to use the quad function for Simpson’s rule, or write your own code for it. The Wikipedia article on Simpson’s rule seems to me to have code you can adapt to use vectors.
SMY
on 3 Jun 2016
Again.. thank you so much but unfortunately it seems difficult for me and I could not understand. :( However, thank you for your time and help.
Star Strider
on 3 Jun 2016
My pleasure.
It is not terribly difficult, but since this sounds like homework, I’m reluctant to develop code and send it to you.
SMY
on 5 Jun 2016
It not really homework to be honest. :) I am research student I really struggle with this coding since this not my area of research.
Star Strider
on 5 Jun 2016
Since it’s research, I’ll provide as much help as I can.
The problem is that every description I can find for Simpson’s rule indicates that it is only used with functions. I could find no references to it being used to integrate data. The result you got with cumtrapz is likely the best result you can get with empirical data.
You could always do a function fit to it (for example, a polynomial using polyfit and polyint to integrate it), or preferably a non-linear function that describes the process that created your data (estimating the parameters of that model), then integrate that function (analytically if possible), or with Simpson’s rule (the quad function), or integral.
SMY
on 5 Jun 2016
Edited: Star Strider
on 5 Jun 2016
Yes, I did it. I identified the best fit using polynomial quadrant.
What I found was when I used both quad and integral function the result will be the total of area under graph not the point instead. I also try quadv to find from 1 interval to another interval but it seems not right.
I found and currently try this -> http://uk.mathworks.com/matlabcentral/fileexchange/28726-simpson-s-rule-integration and really hope it can works.
Star Strider
on 5 Jun 2016
I have to admit that I did not look in the File Exchange (that I usually check first), probably because cumtrapz does what you want. That author apparently made Simpson’s rule work for vectors.
I hope it works for you. Please post back here if there is a significant difference between the cumtrapz and the Simpson’s rule function results. (I would trust the cumtrapz result.)
SMY
on 5 Jun 2016
For your information, my data is about signal processing. Yes, indeed. based on the theory the trapezium's rule better than simpson's rule and since I working with big frequency (Hz) therefore the trapezium will be better. But for my work, i need to check both for preparing myself when I presenting later.
I will let you know and share here. If not, it seems I give up. :D
Star Strider
on 5 Jun 2016
Interesting. I do a lot of biomedical signal processing.
You’re integrating accelerometer signals, so I would begin by doing a Fourier transform on them (each of the ‘X’, ‘Y’ and ‘Z’ directions) to define the signal spectrum and the noise spectrum.. In my experience they are easily separable. Then design a bandpass filter to separate out the gravitational constant and the noise (my filter design procedure is here: How to design a lowpass filter for ocean wave data in Matlab? although there are several ways to design discrete filters in MATLAB), then do the integrations on the filtered signals. Filter design is inherently experimental with respect to particular signals, so it will require some experimentation to get the filter characteristic and signal result that you want. Use the same filter on all of the channels, since you have used all of the channels to design your filter.
It is always best to use the fft function to analyse your signals first. Then filter them to eliminate as much noise as possible without eliminating any of your signal energy spectrum, then do whatever other processing on the filtered signals that you want to.
SMY
on 5 Jun 2016
Biomedical signal processing? Interesting. Mine is vibrational signal processing. My PhD is working in vibrations in steering wheel.
Thank you so much for the knowledge sharing. :)
Star Strider
on 5 Jun 2016
As always, my pleasure!
Steering wheel vibrations can contribute to human workload, and therefore to fatigue, and lower situational awareness. This relates to the postural reflexes that tend to keep the steering wheel steady, and so compensate for position changes constantly. (Workload metrics and related areas were also an area of my research many years ago.) Yours is an important area of human workload research, even if you never considered it in that context. Similar problems are acoustic noise and undercarriage vibrations, for the same reasons.
SMY
on 6 Jun 2016
I solved it!!
By referring to (https://youtu.be/364T-wFzBFM?list=PLgzRuzNES8Up4ib7hgo3O2y38LSQK138z)
From both trapezium and simpson's rules, from the graph it shows that simpson's rule was more clearly while trapezium bit compress maybe because simpson's rules are summations for 3 interval.
But for signal processing presentation, I will discuss further later with my supervisor.
But for now, to solve the integration by Simpson's rule, please refer to (https://youtu.be/364T-wFzBFM?list=PLgzRuzNES8Up4ib7hgo3O2y38LSQK138z)
Thank you Star Strider for your time!
Star Strider
on 6 Jun 2016
Congratulations!
Thank you for the links. I will look at them.
As always, my pleasure!
farzad
on 16 Apr 2020
dear Star, how do we check that we have not eliminated any energy from the signal by filtering it ? and is CWT the best option to filter ?
More Answers (0)
See Also
Categories
Find more on Signal Processing Toolbox 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!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)