MATLAB: How to use FILTFILT function on DFILT objects in the Signal Processing Toolbox 6.12(R2009b)

matrixnearlySignal Processing Toolboxsosunstable

I have created a filter using FDATOOL. When I export the filter to the workspace, it is stored as a DFILT object. When I extract the numerator and denominator of this object and pass them as arguments to FILTFILT, I receive unexpected results due to loss of numerical precision in converting the SOS matrix to a transfer function.
How may I use FILTFILT with a DFILT object without losing precision?

Best Answer

This enhancement has been incorporated in Release 2011a (R2011a). For previous product releases, read below for any possible workarounds:
The ability to use FILTFILT with DFILT objects is not available in Signal Processing Toolbox.
To work around this issue, use the following steps. The key is to work the SOS structure to retain numerical precision.
1) Set the 'PersistentMemory' attribute to true for the DFILT object.
2) Depending on your need, you may want to define certain initial states for the filter. Additionally, you may choose to expand the input signal to flush out the transients in the end. For details, please consult the references listed in the following document:
<http://www.mathworks.com/help/releases/R2011b/toolbox/signal/ref/filtfilt.html>
3) Filter the input using FILTER:
filter(dfiltobj,filt_input)
4) Reverse the output sequence and pass it through the filter again.
You may find the 'flipud' command useful for this. For more information please consult the documentation by executing the following at the MATLAB prompt:
doc flipup
5) Reverse the output sequence
6) Remove the transient guard if you used one in step 2.