filtfilt() does not return expected results

2 views (last 30 days)
mounakias
mounakias on 18 Apr 2015
Commented: Star Strider on 18 Apr 2015
I am reading the recording 'sig' from a .csv file with the xlsread() command and then proceed to filter it with a bandpass filter designed with the designfilt() command. When I use the filter() command to filter the recording it works fine, but when I use filtfilt() it returns a completely different result and does not just compensate for the delay.
Below is the part of the code regarding the filter design and filtering of the signal. I have also attached both the .csv and .m files. Thanks
d = designfilt('bandpassiir', ... % Response type
'StopbandFrequency1',0.99*Fpass1, ... % Frequency constraints
'PassbandFrequency1',Fpass1, ...
'PassbandFrequency2',Fpass2, ...
'StopbandFrequency2',1.01*Fpass2, ...
'StopbandAttenuation1',80, ... % Magnitude constraints
'PassbandRipple',1, ...
'StopbandAttenuation2',80, ...
'DesignMethod','butter', ... % Design method
'MatchExactly','passband', ... % Design method options
'SampleRate',Fs); % Sample rate
filt_sig1 = filter(d, sig);
filt_sig2 = filtfilt(d, sig);

Answers (1)

Star Strider
Star Strider on 18 Apr 2015
I don’t completely understand the problem you are having.
The two filtering algorithms differ in that filtfilt is phase-neutral, while filter is not. Therefore, the outputs of the two filtering functions will differ, and by the design of the filtering algorithms.
  2 Comments
mounakias
mounakias on 18 Apr 2015
As I have written in the description, filtfilt() does not just compensate for the delay. Theoretically the signal after filtfilt() should be the same as after filt(), but with the delay eliminated. However, the code I have attached gives completely different result for filtfilt() and filter().
Star Strider
Star Strider on 18 Apr 2015
Note that ‘phase neutral’ also implies ‘no phase distortion’. ‘Phase distortion’ is the rule rather than the exception for all filters except for the algorithm used in filtfilt, and in hardware the Gaussian filter design.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!