I'm trying to design an analog Butterworth filter using the buttord
function (actually, I'm porting a program where this function is called from MATLAB to Python).
My parameters are:
Passband frequency (Fp) = 10 Hz, giving Wp = 2*pi*10 Hz
Stopband frequency (Fs) = 100 Hz, giving Ws = 2*pi*100 Hz
The passband and stopband losses/attenuations (Rp, Rs) are 3 and 80 dB respectively.
In MATLAB I use this code:
Wp = 2 * pi * 10
Ws = 2 * pi * 100
Rp = 3
Rs = 80
[N, Wn] = buttord(Wp, Ws, Rp, Rs, 's')
that gives me N = 5
, Wn = 99.581776302
.
In SciPy I tried to do the same:
from numpy import pi
from scipy import signal
Wp = 2 * pi * 10
Ws = 2 * pi * 100
Rp = 3
Rs = 80
(N, Wn) = signal.buttord(Wp, Ws, Rp, Rs, analog=True)
and I get N = 5
and Wn = 62.861698649592753
. Wn is different than the value that MATLAB gives, and is strangely close to Wp. What is wrong here?
Digging into SciPy's sources and issues, I found this pull request which might explain things: turns out MATLAB and SciPy have different design goals (MATLAB tries to optimize for matching the stopband frequency and SciPy tries to optimize for matching the passband frequency).
I'm using MATLAB R2013a, Python 3.4.2 and SciPy 0.15.0 if that matters.