ParksMcClellan optimal FIR filter design
b = firpm(n,f,a)
b = firpm(n,f,a,w)
b = firpm(n,f,a,ftype)
b = firpm(n,f,a,lgrid)
[b,err] = firpm(___)
[b,err,res] = firpm(___)
b = firpm(n,f,fresp,w)
b = firpm(n,f,fresp,w,ftype)
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.
firpm
designs a linearphase FIR filter using the ParksMcClellan
algorithm [1]. 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.
The relationship between the f
and a
vectors in
defining a desired frequency response is shown in the illustration below.
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 [5] 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.
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 (MATLAB) for
more information.
[1] 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.
[2] 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.
[3] Parks, Thomas W., and C. Sidney Burrus. Digital Filter Design. New York: John Wiley & Sons, 1987, p. 83.
[4] 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.
[5] Oppenheim, Alan V., Ronald W. Schafer, and John R. Buck. DiscreteTime Signal Processing. Upper Saddle River, NJ: Prentice Hall, 1999, p. 486.
butter
 cfirpm
 cheby1
 cheby2
 ellip
 fir1
 fir2
 fircls
 fircls1
 firls
 firpmord
 rcosdesign
 yulewalk