High Pass Butterworth Filter increases unwanted frequencies using Filtfilt

조회 수: 13 (최근 30일)
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!

채택된 답변

Star Strider
Star Strider 2019년 1월 21일
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
KatOz
KatOz 2019년 1월 21일
Thanks, I appreciate the suggestion to use an Elliptical filter.
I did notice that when I increase my cutoff to 10Hz, rather than 2Hz, the odd effect goes away. Would that likely be because the transition region is effectively shifted enough to remove the near-DC frequencies? Also, I understand why being in the transition would possibly cause the frequencies to not be removed, but why would that cause them to be increased compared to the original signal?
Star Strider
Star Strider 2019년 1월 21일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by