How to filter and FFT raw data
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Peter Odedeyi
am 28 Aug. 2019
Kommentiert: Star Strider
am 29 Aug. 2019
Can someone help me with the matlab code:
I have a raw data (attached) from acoustic sensor. I want to filter the signal and carry out fft then plot the graph.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 28 Aug. 2019
I am not certain what you want to do.
One approach:
D = load('exp 8b.txt');
t = D(:,1);
s = D(:,2);
figure
plot(t, s)
grid
title('Original Signal')
xlabel('Time')
ylabel('Amplitude')
sm = mean(s);
L = size(D,1);
Ts = mean(diff(t));
Fs = 1/Ts;
Fn = Fs/2;
FTs = fft(s-sm)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FTs(Iv))*2)
grid
title('Original Signal')
xlabel('Frequency')
ylabel('Amplitude')
sdn = wdenoise(s); % Denoise (Wavelet Toolbox)
figure
plot(t, sdn)
grid
title('Denoised Signal')
xlabel('Time')
ylabel('Amplitude')
Wp = [859 862]/Fn; % Passband Normalised
Ws = [855 865]/Fn; % Stopband Normalised
Rp = 1; % Passband Ripple (Irrelevant in Butterworth)
Rs = 50; % Stopband Attenuation
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp); % Zero-Pole-Gain
[sos,g] = zp2sos(z,p,k); % Second-Order Section For Stability
figure
freqz(sos, 2^16, Fs) % Filter Bode Plot
s_filt = filtfilt(sos, g, s); % Filter Signal
figure
plot(t, s_filt)
grid
title('Filtered Signal')
xlabel('Time')
ylabel('Amplitude')
s_filt = filtfilt(sos, g, sdn); % Filter Denoised Signal
figure
plot(t, s_filt)
grid
title('Filtered Denoised Signal')
xlabel('Time')
ylabel('Amplitude')
Your signal has significant broadband noise, and a wavelet denoising step is the only way to deal with that. See the documentation for wdenoise (R2017b and later releases) for details on the function.
There appears to be a frequency peak at about 861 Hz, and the bandpass filter here selectively (and efficiently) filters the region from 859 Hz to 862 Hz.
Expertiment to get the result you want.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matched Filter and Ambiguity Function finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!