0
$\begingroup$

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?

$\endgroup$
4
  • 1
    $\begingroup$ 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". $\endgroup$
    – user7358
    Commented Feb 15, 2014 at 15:31
  • $\begingroup$ Unfortunately, i don't have matlab. So can i assume that the output is a vector of numbers? $\endgroup$ Commented Feb 15, 2014 at 17:34
  • 4
    $\begingroup$ Yes, the output will be a vector containing the filter taps. You can download Octave (a free Matlab clone) and try for yourself. $\endgroup$ Commented Feb 15, 2014 at 20:30
  • $\begingroup$ @user7358 the order (80) is the number of delays in the filter and the number of coefficients (81) is the number of taps. $\endgroup$
    – bhillam
    Commented May 5, 2015 at 8:26

1 Answer 1

3
$\begingroup$

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}$

$\endgroup$
3
  • $\begingroup$ Thanks for the input! One last qns, so num will contains the coefficients? $\endgroup$ Commented Feb 16, 2014 at 7:55
  • 1
    $\begingroup$ num is a vector and represents the coefficients of the filter. Thanks $\endgroup$
    – lennon310
    Commented Feb 16, 2014 at 15:25
  • $\begingroup$ @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). $\endgroup$
    – jojeck
    Commented Aug 10, 2014 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.