[SciPy-User] butter() and filtfilt() - differences between MATLAB and scipy

Tristan Strange tristan.strange@gmail....
Fri Jun 28 05:08:32 CDT 2013


Hi all,

I'm porting a script form MATLAB to Python and am getting very different
results form the butter functions in the languages.

In MATLAB when I do the following:

w=2/(256/2);
[b,a]=butter(9,w,'low');

b comes out as a matrix containing :

2.8109e-15   2.5298e-14   1.0119e-13   2.3612e-13   3.5418e-13   3.5418e-13
2.3612e-13   1.0119e-13   2.5298e-14   2.8109e-15

When done in Python using scipy.signal's butter like so:

w = 2.0 / (256.0 / 2.0)
b, a = butter(9, w, 'low')

I get the following array with only a single value for b:

array([  2.81094410e-15])

and the following warning is issued:

/usr/lib/python2.7/dist-packages/scipy/signal/filter_design.py:288:
BadCoefficients: Badly conditioned filter coefficients (numerator): the
results may be meaningless  "results may be meaningless", BadCoefficients)

Both functions in MATLAB and Python output the same a.

When using these values in filtfilt() I get totally different results. I've
tried exporting b from MATLAB and loading it in to Python and passing that
in to filtfilt() but still get totally diffreent results.

Can anyone tell me how to port this MATLAB code to Python such that the
results are the same or explain what the problem is?

Many thanks,
Tristan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20130628/7f2f80c7/attachment.html 


More information about the SciPy-User mailing list