Prev Next pbfir

Parks-Burrus Style FIR Filter Design
Syntax y = pbfir(a,Ntaps) ("RECTANGULAR" assumed)
Syntax y = pbfir(a,Ntaps,wintype) (all windows except "GAUSSIAN" and "KAISER")
Syntax y = pbfir(a,Ntaps,wintype,winparam) ("GAUSSIAN" and "KAISER" windows only)
Include: include spt\pbfir.oms
See Also linfir , hilbert , pwlfir , pbfir , rcfir , srrcfir

      a        = INPUT, COLUMN VECTOR, any numerical type. The frequency response
                 template representing the desired  magnitude of frequency response samples.
                 Samples are evenly spaced, ascending order, first sample is at f=0. Length is
                 (Ntaps-1)/2 for ODD length filters, Ntaps/2 for EVEN lengths. Coerced to DOUBLE
                 for local processing.
      Ntaps    = INPUT, SCALAR, any numerical type. Filter length in
                 [taps]. Coerced to INTEGER. Must be minimum of Ntaps=3.
      wintype  = INPUT, string. One of ["RECTANGULAR"|
      winparam = INPUT, scalar, any numerical type. Parameter
                 used by GAUSSIAN or KAISER window functions.
                 Coerced to DOUBLE.
   RETURN:       DOUBLE, COLUMN VECTOR, FIR filter coefficients of length Ntaps.


Linear-phase FIR filter design based on the method described by Parks-Burrus.

Creates a linear phase FIR filter vector that approximates the frequency response magnitude values passed in through vector 'a'. Frequency response values are assumed to start with a sample at zero frequency (element a(1)), are evenly spaced thereafter, and are coerced to DOUBLE for local processing (function only approximates a real-valued frequency response). The taps length of the filter is passed in through 'Ntaps' which is coerced to INTEGER for local processing. An optional window function may be specified in addition. For Ntaps=ODD a TYPE 1 design is performed; Ntaps=EVEN produces a TYPE 2 design.

When input tap length 'Ntaps' is ODD-valued the length of column vector 'a' must be at least (Ntaps-1)/2 elements long. For tap lengths that are EVEN-valued the length of 'a' must be at least Ntaps/2 elements long. In both cases excess length is discarded. The assumed frequency spacing of the 'a' frequency response values is 'fs/Ntaps' where 'fs' is the system sampling frequency. Thus, the smallest resolution for the frequency response template given in the vector 'a' is dependent on the filter tap length and is fixed at fs/Ntaps Hz.

A window function may be applied to the resulting FIR filter. 'wintype' is a string specifying the window type to be applied. 'winparam' is the numerical parameter used with the GAUSSIAN and KAISER window functions. If you leave off 'wintype' and 'winparam', a "RECTANGULAR" window is assumed. For windows other than "GAUSSIAN" and "KAISER", 'winparam' may be omitted. Error handling is done by 'winddata()' function.

Create a simple lowpass filter, fs = 1000 Samples/Sec, fc = 125 Hz.

#--- TYPE 2 design, Ntaps=EVEN, sample at f=0, length(A) = Ntaps/2
#--- Ideal Lowpass filter at fc=125, fs=1000

Ntaps   = 50;            # Filter Tap Length
wintype = "HAMMING";     # Window type
fs      = 1000d0;        # Sampling Rate [Samp/Sec(Hz)]
fc      =  125d0;        # Cutoff Frequency [Hz]
df      = fs/Ntaps;      # Frequency Resolution per point
                         # fs/Ntaps = 1000/50 = 20 Hz

Alength = Ntaps/2;       # Minimum length for amplitude mask

#--- Form frequency response template ---

n  = seq(Ntaps)-1;           # Index vector for amplitude template.
f0 = n*df;                   # Make a freq vector with "df" spacing, for plotting template.
A  = double(f0<=fc);         # Make the amplitude template. A lowpass filter
                             # where everything at or below "fc" is 1.0; 0.0 otherwise.
h  = pbfir(A,Ntaps,wintype); # Make the filter

A plot illustrating the filters' characteristics is:


Parks and Burrus, "Digital Filter Design", New York, Wiley, 1987.