Skip to content
Advertisement

Butterworth filters look very strange as increasing order

I’m trying to design a simple Butterworth bandpass filter in SciPy, and I’m running into some strange results.

JavaScript

This is giving strange results, as can be seen from the image below (Butterworth filters from order 1-10). I thought the filter was supposed to become increasingly rectangular as the order increased?

enter image description here

Does anyone know how to design a simple Butterworth filter in SciPy?

Advertisement

Answer

The frequency response of the Butterworth filter is not real-valued. When plotting the complex-valued response using plt.plot(), only the real component is shown. You should see a warning:

JavaScript

To examine the filter’s gain, plot the magnitude of the frequency response:

JavaScript

You will see an increasingly square response, as expected:

output of OP's code with small change proposed here

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement