Documentation Center |
Frequency sampling-based finite impulse response filter design
b = fir2(n,f,m)
b = fir2(n,f,m,window)
b = fir2(n,f,m,npt)
b = fir2(n,f,m,npt,window)
b = fir2(n,f,m,npt,lap)
b = fir2(n,f,m,npt,lap,window)
fir2 designs frequency sampling-based digital FIR filters with arbitrarily shaped frequency response.
Note Use fir1 for windows-based standard lowpass, bandpass, highpass, and bandstop configurations. |
b = fir2(n,f,m) returns row vector b containing the n+1 coefficients of an order n FIR filter. The frequency-magnitude characteristics of this filter match those given by vectors f and m:
f is a vector of frequency points in the range from 0 to 1, where 1 corresponds to the Nyquist frequency. The first point of f must be 0 and the last point 1. The frequency points must be in increasing order.
m is a vector containing the desired magnitude response at the points specified in f.
f and m must be the same length.
Duplicate frequency points are allowed, corresponding to steps in the frequency response.
Use plot(f,m) to view the filter shape.
The output filter coefficients, b, are ordered in descending powers of z.
fir2 always uses an even filter order for configurations with a passband at the Nyquist frequency. This is because for odd orders, the frequency response at the Nyquist frequency is necessarily 0. If you specify an odd-valued n, fir2 increments it by 1.
b = fir2(n,f,m,window) uses the window specified in the column vector window. The vector window must be n+1 elements long. If no window is specified, fir2 uses a Hamming window (see hamming) of length n+1.
b = fir2(n,f,m,npt,window) specifies the number of points, npt, for the grid onto which fir2 linearly interpolates the frequency response with or without the window specification. npt must be greater than 1/2 the filter order (npt>n/2). If desired, you can interpolate f and m before passing them to fir2.
b = fir2(n,f,m,npt,lap,window) specify the size of the region, lap, that fir2 inserts around duplicate frequency points, with or without a window specification.
See Algorithms for more on npt and lap.
[1] Mitra, Sanjit K. Digital Signal Processing: A Computer Based Approach. New York: McGraw-Hill, 1998, pp. 462–468.
[2] Jackson, L. B. Digital Filters and Signal Processing. 3rd Ed. Boston: Kluwer Academic Publishers, 1996, pp. 301–307.
butter | cheby1 | cheby2 | ellip | fir1 | firpm | maxflat | yulewalk