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

Roger Fearick roger.fearick@uct.ac...
Fri Jun 28 06:23:42 CDT 2013


You're using Python 2.7: maybe 2/(256/2) = 0.
________________________________

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

________________________________
UNIVERSITY OF CAPE TOWN

This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 9111. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20130628/2830d273/attachment.html 


More information about the SciPy-User mailing list