# Matlab FIR filter numerator coefficients to python

I created a equiripple FIR filter in Matlab using filterDesigner and exported it to an ASCII file. The file contains the numerator values as a list of 51 numbers tagged under Numerator: (this is all the data the file has)

Now I read this 51 values into a python array named num and try to recreate the filter in python using scipy.signal.lfilter

from scipy import signal

x_filt = signal.lfilter(num, np.ones_like(num), x)  # x is my input signal


This is my original signal

Here's the filtered signal from Matlab (Fpass-800Hz, Fstop-1200Hz)

But this is what I get from the python code using scipy.signal.lfilter

Can somebody please show me what I am doing wrong here?

EDIT: (After getting the answer) Here's the correct python code

x_filt = signal.lfilter(num, 1, x)

• You don't want np.ones_like(num) in the denominator. That's making a denominator of all ones, with lots of possibly unstable poles. Your denominator in Python needs to be [1,0,0,0,0,0,...]. Or just [1] if possible.
– Peter K.
Nov 20 '20 at 18:42
• It worked. thanks. Can you please add this as an answer? Nov 21 '20 at 9:52
• Done! Glad it worked out.
– Peter K.
Nov 21 '20 at 16:32

You don't want np.ones_like(num) in the denominator. That's making a denominator of all ones, with lots of possibly unstable poles. Your denominator in Python needs to be [1,0,0,0,0,0,...]. Or just [1] if possible.