Discret low-pass-filter for velocity data
1 view (last 30 days)
Show older comments
I got a data set of velocity over time. I am trying to calculate the first and second derivative, but the data set is really noisy. How can I filter the data, so that the derivative yields realistic results.
0 Comments
Accepted Answer
Star Strider
on 13 Apr 2022
That the data are ‘really noisy’ unfortunately says nothing about the nature of the noise. If the noise is band-limited (determine this by doing a Fourier transform on it), the noise can likely be eliminated with a frequency-selective filter. For broadband noise (and your signal since the nature of the noise is not described), I would use the sgolayfilt (Savitzky-Golay filter) function. I usually use an order 3 polynomial, and then experiment with the window length until I get the result that I want.
Take the derivatives of the filtered signal.
dydx = gradient(y) ./ gradient(x);
d2ydx2 = gradient(dydx) ./ gradient(x);
This does not require that the signals be sampled consistently, however for all other signal processing (including the fft function), they must be. Use the resample function to resample them to consistent sampling intervals if they are not. To determine sampling frequency consistency, calculate:
tsstd = std(diff(x))
where ‘x’ is the independnet variable. For a consistently-sampled signal, this should be near zero (on the order of 1E-15 or so).
.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!