Signal Processing Toolbox | Help Desk |
remez
Parks-McClellan optimal FIR filter design.
b = remez(n,f,a) b = remez(n,f,a,w) b = remez(n,f,a,'ftype
') b = remez(n,f,a,w,'ftype
')
remez
designs a linear-phase FIR filter using the Parks-McClellan algorithm [1]. The Parks-McClellan 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 hence are sometimes called equiripple filters.
b = remez(n,f,a)
returns row vector b
containing the n
+1 coefficients of the order n
FIR filter whose frequency-amplitude characteristics match those given by vectors f
and a
.
The output filter coefficients (taps) in b
obey the symmetry relationf
and a
specify the frequency-magnitude 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 half the sampling frequency (the Nyquist frequency). The frequencies must be in increasing order.
a
is a vector containing the desired amplitudes at the points specified in f
.
The desired amplitude 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 at frequencies between pairs of points (f(k), f(k+1)) for k even is unspecified. The areas between such points are transition or "don't care" regions.
f
and a
must be the same length. The length must be an even number.
f
and a
vectors in defining a desired frequency response is
remez(n,f,a,w)
uses the weights in vector w
to weight the fit in each frequency band. The length of w
is half the length of f
and a
, so there is exactly one weight per band.
b = remez(n,f,a,'ftype
')
and
b = remez(n,f,a,w,'ftype
')
specify a filter type, where ftype
is
hilbert
, for linear-phase filters with odd symmetry (type III and type IV)
The output coefficients in b
obey the relation b(k) = -b(n + 2 -k), k = 1,...,n + 1. This class of filters includes the Hilbert transformer, which has a desired amplitude of 1 across the entire band.
For example,
h = remez(30,[0.1 0.9],[1 1],'Hilbert');designs an approximate FIR Hilbert transformer of length 31.
differentiator
, for type III and IV filters, using a special weighting technique
For nonzero amplitude bands, it weights the error by a factor of 1/f so that the error at low frequencies is much smaller than at high frequencies. For FIR differentiators, which have an amplitude characteristic proportional to frequency, these filters minimize the maximum relative error (the maximum of the ratio of the error to the desired amplitude).
f = [0 0.3 0.4 0.6 0.7 1]; a = [0 0 1 1 0 0]; b = remez(17,f,a); [h,w] = freqz(b,1,512); plot(f,a,w/pi,abs(h))
![]()
remez
is a MEX-file version of the original FORTRAN code from [1], altered to design arbitrarily long filters with arbitrarily many linear bands.
remez
designs type I, II, III, and IV linear-phase 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 obtained with the 'hilbert'
and 'differentiator'
flags. The different types of filters have different symmetries and certain constraints on their frequency responses (see reference [5] for more details):
|
---|
Filter order must be 3 or more.
There should be one weight per band.
Frequency and amplitude vectors must be the same length.
The number of frequency points must be even.
Frequencies must lie between 0 and 1.
Frequencies must be specified in bands.
Frequencies must be nondecreasing.
Adjacent bands not allowed.
A more serious warning message is
-- Failure to Converge -- Probable cause is machine rounding error.In the rare event that you see this message, it is possible that the filter design may still be correct. Verify the design by checking its frequency response.