How to implement either a High/Low Pass filter on accelerometer data.
128 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello all,
I have collected data from an accelerometer and have been reading and attempting to understand past posts for hours now however I don't believe I know enough about signal processing to properly implment the filter I need. For my accelerometer, I set the output data rate to 50hz so the bandwidth would be 25hz and sampled at 10hz (10 times /sec) to account for Nyquist.
My data is highly noisy and I am trying to extract frequencies which based on similar research in my field should be between 0.1-1hz range. Also from research papers I've read it seems previous research either uses a high pass butterworth filter or a lowpass filter.
I have implemented an FFT first however I'm not quite sure how to discern it and accuratley apply a filter passing the signal in the desired range through to obtain a filtered dataset. I'll provide an image and code below (not sure if correct).
I would really appreciate if someone would step me through how to implement a filter on my dataset so I can clearly discern the peak frequencies in my data and have a filtered dataset going foward. I'm pretty amateur to both signal processing and Matlab! Thank you, I'd really like to understand it.
X = readmatrix('30min.CSV');
%plot(X)
Y = fft(X);
L = 133361; %Length of matrix
Fs = 10; %Sampling Frequency (hz)
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
title("Single-Sided Amplitude Spectrum of X(t)")
xlabel("f (Hz)")
ylabel("|P1(f)|")
0 commentaires
Réponses (1)
Star Strider
le 28 Sep 2022
‘For my accelerometer, I set the output data rate to 50hz so the bandwidth would be 25hz and sampled at 10hz (10 times /sec) to account for Nyquist.’
It is difficult for me to interpret this. If the sampling frequency is 50 Hz, the Nyquist frequency is 25 Hz, so it should be relatively straightforward to filter a signal in the range of 0.1 Hz to 1 Hz.
The signal appears to have broadband noise. The easiest way to eliminate that is with the Savitzky-Golay filter (sgolayfilt function) since a frequency-selective filter will passd the noise as well as the signal in its passband. Use the bandpass , highpass or lowpass functions for the other filtering, and specify 'ImpulseResponse','iir' for best results. Those functions will design a very efficient elliptic filter for each.
4 commentaires
Star Strider
le 29 Sep 2022
The Savitzky-Golay filter seems to have reduced much of the noise, as well as the signal energy.
If you want to filter the signal between 0.01 Hz and 2 Hz, use the bandpass function instead. The syntax is almost the same.
I do not have the data, so one way to determine if the sampling intervals are regular is with:
Tsmean = mean(diff(t))
Tsstd - std(diff(t))
The ‘Tsmean’ value will be the mean sampling interval (the inverse of the sampling frequency, so ideally about 0.1 here), and ‘Tsstd’ the standard deviation of the sampling intervals. It should be on the order of indicating that the sampling intervals are regular. If it is on the order of for example, the data need to be resampled (using the link I posted earlier) to a constant sampling interval in order for the digital filters to work correctly.
The documentation does not specify the reason that ‘framelen’ needs to be odd. I suspect it is so that it is symmetrical about a specific value, that value corresponding to the output. I have not explored the theory behind it, or read the references.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!