# What does fir1 in matlab does?

May i know what does this function do in matlab?

num = fir1(80, [5Hz, 50Hz]);


I know that 5 Hz is the low cut-off freq and 50 Hz is the high cut-off freq. I'm not sure why it is 80 for the first parameter.

What will be the output of this function?

• 80 would be the order (number of coefficients) of the generated filter. Why don't you just type that into some free replacement of matlab and see the output? By the way, matlab won't understand "Hz". Commented Feb 15, 2014 at 15:31
• Unfortunately, i don't have matlab. So can i assume that the output is a vector of numbers? Commented Feb 15, 2014 at 17:34
• Yes, the output will be a vector containing the filter taps. You can download Octave (a free Matlab clone) and try for yourself. Commented Feb 15, 2014 at 20:30
• @user7358 the order (80) is the number of delays in the filter and the number of coefficients (81) is the number of taps. Commented May 5, 2015 at 8:26

You cannot use ordinary frequency values as the input. fir1 requires normalized frequency values that locate within $[0,1]$ where $1$ represents the normalized NYQUIST frequency (half the sampling rate). Suppose your sampling rate is $500$ Hz, the code should be

num = fir1(80, [0.02, 0.2]);


num is a 1*81 vector, and the corresponding filter is

$F(z) = num(1) + num(2)z^{-1} + num(3)z^{-2} + ...num(81)z^{80}$

• Thanks for the input! One last qns, so num will contains the coefficients? Commented Feb 16, 2014 at 7:55
• num is a vector and represents the coefficients of the filter. Thanks Commented Feb 16, 2014 at 15:25
• @lennon310: Then why not to name it as b, which is a general convention instead of coming up with meaningless variable name and copying OP error (who doesn't even know his own variable).
– jojeck
Commented Aug 10, 2014 at 9:04