# Data filtering using Butterworth filter

I want to filter data using Butterworth filter. I am currently using Matlab and I want to know how to do it in Mathematica.

I have the following data:

data1 = Table[
PDF[NormalDistribution[3.5, .8], i] +
PDF[NormalDistribution[6, 1], i], {i, -5, 15, .01}];
noise = RandomReal /@ RandomReal[{-0.2, .2}, Length[data1]];
data2 = data1 + noise;


I filtered this data using Matlab as follows:

[b,a] = butter(8,0.04);

filtfilt(b,a,data2 );


In the previous question's answer, bill s suggested to do it as follows in Mathematica:

RecurrenceFilter[
ToDiscreteTimeModel[ButterworthFilterModel[{2, 0.04}], 1], data2
]


The result is as follows:

The problem I am facing is whatever I change the filter order and frequency, I am not able to produce the same filtered data as I am getting from Matlab.

Can someone suggest for me what to do and what values to use to get the same filtered data as I am getting from Matlab?

Thanks

-
filtfilt does a forward-backward filtering. Have you tried filtering, reversing the output, filtering again and finally reversing again in Mathematica? –  The Toad Apr 21 '14 at 5:24

filtfilt does a forwards and then a backwards filtering, as rm -rf suggests. To filter data in this way, you might try
forwards = RecurrenceFilter[ToDiscreteTimeModel[ButterworthFilterModel[5], 1], data];