Converting tremor data in to frequency and filter data
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Can anyone help in apply fft and filtering to my IMU sensor data for detecting tremor
Respuestas (1)
Star Strider
el 13 de Sept. de 2022
Editada: Star Strider
el 14 de Sept. de 2022
The fft plots are straightforward, however only the acceleration signals make sense. The ‘Gyr’ signals exhibit broadband noise.
How do you want to process them?
One approach —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1124040/labeled%20final%20data.csv')
Acc = T1{:,1:3}
Gyr = T1{:,4:6};
Data = [Acc Gyr];
Fs = 1; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
NrSp = size(Data,2); % Number Of Subplots
L = size(Data,1); % Length Of Data Vectors
t = linspace(0, L-1, L)/Fs; % Time Vector
NFFT = 2^nextpow2(L); % For Efficiency
FTData = fft(Data - mean(Data),NFFT)/L; % Fopurier Transform
Fv = linspace(0, 1, NFFT/2-1)*Fn; % Frequency Vector (For Plots)
Iv = 1:numel(Fv); % Index Vector (For Plots)
figure
sp = [1:2:NrSp 2:2:NrSp]; % Order 'subplot' Plots
for k = 1:NrSp
subplot(3,2,sp(k))
plot(Fv, abs(FTData(Iv,k))*2) % Plot Fourier Transforms
grid
xlabel('Frequency')
ylabel('Magnitude')
xlim([0 Fn/20])
% xlim([5 10])
title(sprintf('Column %d',k))
end
sgtitle('Fourier Transform of Data')
figure
sp = [1:2:NrSp 2:2:NrSp];
for k = 1:NrSp
subplot(3,2,sp(k))
plot(t, Data(:,k))
grid
ylim([-3 3])
xlabel('Time')
ylabel('Amplitude')
title(sprintf('Column %d',k))
end
sgtitle('Original Time-Domain Data')
Wp = [0.0001 0.005]/Fn; % Define Passband In Hz, Normalise To (0,pi)
Ws = Wp.*[0.95 1.05]; % Stopband (Normalised)
Rs = 50; % Stopband Ripple (Attenuation) dB
Rp = 1; % Passband Ripple dB
[n,Wn] = ellipord(Wp,Ws,Rp,Rs); % Calculate Filter Order
[z,p,k] = ellip(n,Rp,Rs,Wp); % Design Filter
[sos,g] = zp2sos(z,p,k); % Implement Filter As Second-Order-Section Representation
figure
freqz(sos, 2^16, Fs) % Filter Bode Plot
set(subplot(2,1,1), 'XLim',[0 0.01])
set(subplot(2,1,2), 'XLim',[0 0.01])
Data_Filt = filtfilt(sos,g,Data);
figure
for k = 1:NrSp
subplot(3,2,sp(k))
plot(t, Data_Filt(:,k))
grid
ylim([-1 1]*0.75)
xlabel('Time')
ylabel('Amplitude')
title(sprintf('Column %d',k))
end
sgtitle('Time-Domain Plots of Bandpass (0.0001 - 0.005 Hz) Filtered Data')
EDIT — (14 Sep 2022 at 11:40)
Changed ‘Fs’ and filter passbands to conform to the 1 Hz sampling frequency.
.
12 comentarios
Ver también
Categorías
Más información sobre Analog Filters en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!