Clear Filters
Clear Filters

Extraction of filter used in filtfilt

7 views (last 30 days)
Riccardo Sorvillo
Riccardo Sorvillo on 15 May 2020
Commented: Paul on 14 Apr 2023
Hello world!
I hope that my question is not trivial, but I am stuck on this.
I am filtering accelerometer signal with a Butterworth digital filter, say order 2 lowpass. In order to eliminate phase delays, I chose function filtfilt to apply the filter to the data. According to its documentation (see here), this function guarantees zero-phase distortion applying the filter in both forward and inverse direction, thus resulting in a filter with:
  • transfer function equal to the squared magnitude of the original filter transfer function;
  • order that is double the order of the filter specified by b and a.
I would like to visualize the transfer function of this resulting filter: is it possibile to extract the magnitude and phase behaviour of the filter applied by filtfilt?
For magnitude it would be enough (I guess) to square it, but how to take into account the doubled order? My code up to now reads:
[Num, Den] = butter(2,100/1e5,'low'); % to create filter
dataflt = filtfilt(Num,Den,data); % to filter data
Dflt = freqz(num2,den2);
figure
subplot(2,1,1)
plot(f,mag2db(abs(Dflt).^2));
subplot(2,1,2)
plot(f,unwrap(angle(Dflt)));
Thank you in advance for your help.

Answers (1)

Ryan Gellner
Ryan Gellner on 13 Apr 2023
I have the same question, and was disappointed to see no one had attempted an answer to this one. I believe you are spot on with squaring the magnitudes, but don't know if there is more to it. Thanks for sharing what you've done so far.
  3 Comments
Ryan Gellner
Ryan Gellner on 14 Apr 2023
Thanks Paul for your response. So I take it that the magnitude is "close" to the magnitude squared and the phase response is "close" to zero as a result of using filtfilt - is that correct?
Paul
Paul on 14 Apr 2023
I said the magnitude is probably close to the magnitude squared of the filter. "Probably" in the sense that there may be inputs where it really isn't. I didn't say anything about the phase being close to zero. I updated the post in the linked question in my Answer to illustrate. Please take a look and comment/answer if you feel appropriate.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!