firpm
ParksMcClellan optimal FIR filter design
Syntax
Description
Examples
Input Arguments
Output Arguments
Tips
If your filter design fails to converge, the filter design might not be correct. Verify the design by checking the frequency response.
If your filter design fails to converge and the resulting filter design is not correct, attempt one or more of the following:
Increase the filter order.
Relax the filter design by reducing the attenuation in the stopbands and/or broadening the transition regions.
Algorithms
firpm
designs a linearphase FIR filter using the ParksMcClellan
algorithm [2]. The ParksMcClellan algorithm uses the Remez exchange algorithm and
Chebyshev approximation theory to design filters with an optimal fit between the desired
and actual frequency responses. The filters are optimal in the sense that the maximum
error between the desired frequency response and the actual frequency response is
minimized. Filters designed this way exhibit an equiripple behavior in their frequency
responses and are sometimes called equiripple filters. firpm
exhibits
discontinuities at the head and tail of its impulse response due to this equiripple
nature.
These are type I (n
odd) and type II (n
even)
linearphase filters. Vectors f
and a
specify the
frequencyamplitude characteristics of the filter:
f
is a vector of pairs of frequency points, specified in the range between 0 and 1, where 1 corresponds to the Nyquist frequency. The frequencies must be in increasing order. Duplicate frequency points are allowed and, in fact, can be used to design a filter exactly the same as those returned by thefir1
andfir2
functions with a rectangular (rectwin
) window.a
is a vector containing the desired amplitude at the points specified inf
.The desired amplitude function at frequencies between pairs of points (f(k), f(k+1)) for k odd is the line segment connecting the points (f(k), a(k)) and (f(k+1), a(k+1)).
The desired amplitude function at frequencies between pairs of points (f(k), f(k+1)) for k even is unspecified. These are transition or "don’t care" regions.
f
anda
are the same length. This length must be an even number.
The figure below illustrates the relationship between the f
and
a
vectors in defining a desired amplitude response.
firpm
always uses an even filter order for configurations with even
symmetry and a nonzero passband at the Nyquist frequency. The reason for the even filter
order is that for impulse responses exhibiting even symmetry and odd orders, the
frequency response at the Nyquist frequency is necessarily 0. If you specify an
oddvalued n
, firpm
increments it by 1.
firpm
designs type I, II, III, and IV linearphase filters. Type I
and type II are the defaults for n
even and n
odd,
respectively, while type III (n
even) and type IV
(n
odd) are specified with 'hilbert'
or
'differentiator'
, respectively, using the
ftype
argument. The different types of filters have different
symmetries and certain constraints on their frequency responses. (See [3] for more details.)
Linear Phase Filter Type  Filter Order  Symmetry of Coefficients  Response H(f),
f = 0  Response H(f),
f = 1
(Nyquist) 

Type I  Even  even: $$b(k)=b(n+2k),\text{\hspace{1em}}k=1,\mathrm{...},n+1$$  No restriction  No restriction 
Type II  Odd  even: $$b(k)=b(n+2k),\text{\hspace{1em}}k=1,\mathrm{...},n+1$$  No restriction  H(1)

Type III  Even  odd: $$b(k)=b(n+2k),\text{\hspace{1em}}k=1,\mathrm{...},n+1$$  H(0)  H(1) 
Type IV  Odd  odd: $$b(k)=b(n+2k),\text{\hspace{1em}}k=1,\mathrm{...},n+1$$  H(0)  No restriction 
You can also use firpm
to write a function that defines the desired
frequency response. The predefined frequency response function handle for
firpm
is @firpmfrf
, which designs a
linearphase FIR filter.
Note
b = firpm(n,f,a,w)
is equivalent to b =
firpm(n,f,{@firpmfrf,a},w)
, where, @firpmfrf
is
the predefined frequency response function handle for firpm
.
If desired, you can write your own response function. Use
help
private/firpmfrf
and see Create Function Handle for
more information.
References
[1] Digital Signal Processing Committee of the IEEE Acoustics, Speech, and Signal Processing Society, eds. Selected Papers in Digital Signal Processing. Vol. II. New York: IEEE Press, 1976.
[2] Digital Signal Processing Committee of the IEEE Acoustics, Speech, and Signal Processing Society, eds. Programs for Digital Signal Processing. New York: IEEE Press, 1979, algorithm 5.1.
[3] Oppenheim, Alan V., Ronald W. Schafer, and John R. Buck. DiscreteTime Signal Processing. Upper Saddle River, NJ: Prentice Hall, 1999, p. 486.
[4] Parks, Thomas W., and C. Sidney Burrus. Digital Filter Design. New York: John Wiley & Sons, 1987, p. 83.
[5] Rabiner, Lawrence R., James H. McClellan, and Thomas W. Parks. "FIR Digital Filter Design Techniques Using Weighted Chebyshev Approximation." Proceedings of the IEEE^{®}. Vol. 63, Number 4, 1975, pp. 595–610.