fir2                 package:signal                 R Documentation

_F_I_R _f_i_l_t_e_r _g_e_n_e_r_a_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     FIR filter coefficients for a filter with the given order and
     frequency cutoffs.

_U_s_a_g_e:

     fir2(n, f, m, grid_n = 512, ramp_n = grid_n/20, window = hamming(n + 1))

_A_r_g_u_m_e_n_t_s:

       n: order of the filter (1 less than the length of the filter) 

       f: band edges, strictly increasing vector in the range [0, 1]
          where 1 is the Nyquist frequency. The first element must be 0
          and the last element must be 1. If elements are identical, it
          indicates a jump in frequency response. 

       m: magnitude at band edges, a vector of 'length(f)'. 

  grid_n: length of ideal frequency response function defaults to 512,
          should be a power of 2 bigger than 'n'. 

  ramp_n: transition width for jumps in filter response defaults to
          'grid_n/20'. A wider ramp gives wider transitions but has
          better stopband characteristics. 

  window: smoothing window. The returned filter is the same shape as
          the smoothing window. 

_D_e_t_a_i_l_s:

_V_a_l_u_e:

     The FIR filter coefficients, an array of length(n+1), of class
     'Ma'.

_A_u_t_h_o_r(_s):

     Original Octave version by Paul Kienzle, pkienzle@user.sf.net.
     Conversion to R by Tom Short.

_R_e_f_e_r_e_n_c_e_s:

     Octave Forge <URL: http://octave.sf.net>

_S_e_e _A_l_s_o:

     'filter', 'Ma', 'fftfilt', 'fir1'

_E_x_a_m_p_l_e_s:

     f = c(0, 0.3, 0.3, 0.6, 0.6, 1)
     m = c(0, 0, 1, 1/2, 0, 0)
     fh = freqz(fir2(100, f, m))
     op = par(mfrow=c(1,2))
     plot(f, m, type = "b", ylab = "magnitude", xlab = "Frequency")
     lines(fh$f / pi, abs(fh$h), col = "blue")
     # plot in dB:
     plot(f, 20*log10(m+1e-5), type = "b", ylab = "dB", xlab = "Frequency")
     lines(fh$f / pi, 20*log10(abs(fh$h)), col = "blue")
     par(op)

