# Why fir1 from MATLAB returns one more sample than its order?

I'm starting to use both the fir1 MATLAB and firwin Scipy functions. Both are window-based FIR filter design methods.

I would like to know why the fir1 filter has one more tap than its order. The firwin filter has the same amount of samples than its order.

MATLAB console:

>> filter = fir1(512, .001);
>> size(filter)

ans =

1   513

>> plot(filter)


Python console:

>>> import matplotlib.pyplot as plt
>>> from scipy import signal
>>> import numpy as np
>>> filter = signal.firwin(numtaps=512, cutoff=.001)
>>> filter.shape
(512,)
>>> plt.plot(filter); plt.show()


The left one is the plot from MATLAB, and then the Python plot:

By incrementing/decrementing one of the arguments, so they can have the same length, both filter values get very close.

There is a slight difference in how python and MATLAB define their input parameters.

MATLAB takes the filter order (which is defined as the greatest tap delay), while Python takes the number of coefficients in the filter. For instance, a filter like

y(n) = ax(n) + bx(n - 1)

Has 2 coefficients, but is a first order filter.