High Pass Butterworth Filter increases unwanted frequencies using Filtfilt
5 views (last 30 days)
Show older comments
Hello,
I am trying to high-pass filter some data using filtfilt. For my application, I only need to effectively remove data close to DC, so I am using a fairly low frequency cutoff.
However, I have noticed that my implementation (butterworth filter using filtfilt) is causing increased spectral content around my cutoff.
Does anyone know why this is happening?
I am thinking it may be a result of having a small ensemble size (50 samples) or possible a filter ripple effect (?)
For example:
N = 50;
data = randn( N,1);
prf = 500;
cutoff = 2;
[B A ] = butter(2, cutoff/ (prf / 2), 'high');
data2 = filtfilt( B,A, data);
figure();
plot( linspace(-prf/2, prf/2, 5000), fftshift( abs( fft( data, 5000))), 'k')
hold on;
plot( linspace(-prf/2, prf/2, 5000), fftshift( abs( fft( data2, 5000))), 'b')
Thanks!
0 Comments
Accepted Answer
Star Strider
on 21 Jan 2019
First, if you want to eliminate the D-C value, simply subtract the mean of your signal from your signal. You do not need to filter it. (Since you are using the randn function, the mean should already be close to 0.) Butterworth filters are popular because they are easier to design than others. However, using the Signal Processing Toolbox functions, this is no longer a significant problem. Elliptical filters are much more efficient. See the documentaion on ellip (link) and related functions (ellipord, zp2sos, and others) as well.
Second, an order 2 filter of any design is not likely to be very efficient. If you have R2018a or later, use the highpass (link) function, although the related bandpass function is usually a better option, since highpass filters amplify noise. If you use the second ‘d’ output from highpass (or any of the others), use it with filtfilt, not filter.
4 Comments
Star Strider
on 21 Jan 2019
My pleasure.
‘Would that likely be because the transition region is effectively shifted enough to remove the near-DC frequencies?’
Yes.
‘... why would that cause them to be increased compared to the original signal?’
I am not certain. Using the transfer function implementation (rather than the second-order-section implementation) could be allowing some amplification at the lowest frequencies.
More Answers (0)
See Also
Categories
Find more on Digital Filter Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!