MATLAB: How to use the “filtfilt” function with a “dffir” filter object created using Filter Designer (fdatool)

datadesignerdffirfdatoolfilterfilteringfiltfiltSignal Processing Toolbox

How can I use the "filtfilt" function with a "dffir" filter object created using Filter Designer (fdatool)?
I have designed a FIR (finite impulse response) filter using the Filter Designer and I have generated MATLAB code for it. The output of my code, "Hd", is a filter object of type "dffir". How could I apply this filter on some data using the "filtfilt" function?

Best Answer

The "filtfilt" function can be executed by inputting the numerator and denominator of a filter, followed by the signal to be filtered. So if you could extract the numerator and denominator of "Hd", you could simply pass these as input arguments to "filtfilt".
The numerator coefficients of "Hd" can be accessed as properties of the filter object with the syntax "Hb.Numerator". Notice that "Hd" is a finite impulse response filter, and hence its denominator coefficient is simply 1.
Based on this information, you could use "filtfilt" with your filter object "Hd" as follows:
y = filtfilt(Hd.Numerator,1,x);
Where "x" is the signal that you are filtering and "y" is the filtered output data.