lowpass filter function doesn't filter out data
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Maria Zilidou
am 26 Mai 2023
Kommentiert: Paul
am 26 Mai 2023
I have an ultrasonic signal (sample rate 199.2 MHz) with random noise which I want to filter out using the lowpass() built-in function in matlab. I want my cut-off frequency to be 9 MHz. In my code this looks like this:
FilteredSignal = lowpass(NoisySignal,9*1e6,1e6*199.2,'ImpulseResponse','iir');
The resulting signal I get after this seems to include even more frequencies instead of filtering out the noise.
How can I fix this?
Any help is much appreciated.
1 Kommentar
Paul
am 26 Mai 2023
Hi Maria,
Is the plot on the right really the output of that lowpass command? Can't recereate that plot ...
load('NoisySignal')
Fs = 199.2e6; % Sampling Frequency (Hz)
N = numel(NoisySignal);
FilteredSignal = lowpass(NoisySignal,9*1e6,1e6*199.2,'ImpulseResponse','iir');
t = (0:N-1)/Fs;
figure
plot(subplot(121),t*1e6, NoisySignal),grid,xlim([0 9]);
plot(subplot(122),t*1e6, FilteredSignal),grid,xlim([0 9])
Akzeptierte Antwort
Star Strider
am 26 Mai 2023
The ‘NoisySignal’ has broadband noise, so a frequency-selective filter can eliminate some of the noise, however not all of it. One option to deal with it is wavelet denoisiung (the wdenoise function), and the other is Savitzky-Golay filtering (the sgolayfilt function).
Using both the lowpass and sgolayfilt gives a reasonable result —
load('NoisySignal')
Fs = 199.2E+6; % Sampling Frequency (Hz)
Fn = Fs/2;
L = numel(NoisySignal)
t = linspace(0, L-1, L)/Fs;
figure
plot(t, NoisySignal)
grid
xlabel('Time')
ylabel('Amplitude')
FT_NS = fft(NoisySignal.'.*hann(L));
Fv = linspace(0, 1, L/2+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FT_NS(Iv))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Magnitude')
xline(9E+6, '-r', 'Filter Cutoff Frequency')
FilteredSignal = lowpass(NoisySignal,9*1e6,1e6*199.2,'ImpulseResponse','iir');
FT_FS = fft(FilteredSignal.'.*hann(L));
figure
plot(t, FilteredSignal)
grid
xlabel('Time')
ylabel('Amplitude')
figure
plot(Fv, abs(FT_FS(Iv))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Magnitude')
xline(9E+6, '-r', 'Filter Cutoff Frequency')
SGorder = 3;
SGframelen = 301;
SGFilteredSignal = sgolayfilt(FilteredSignal, SGorder, SGframelen);
FT_SGFS = fft(SGFilteredSignal.'.*hann(L));
figure
plot(t, SGFilteredSignal)
grid
xlabel('Time')
ylabel('Amplitude')
figure
plot(Fv, abs(FT_SGFS(Iv))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Magnitude')
xline(9E+6, '-r', 'Filter Cutoff Frequency')
Experiment to get the result you want. (The signal length is quite nicely already a power-of-2, making the code a bit more efficient without having to zero-pad it to a power-of-2 for the fft call.)
.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!