Parks-McClellan optimal FIR filter design using the Remez exchange algorithm.
remez( n, f, a, w = rep(1, length(f)/2), ftype = c("bandpass","differentiator","hilbert"), density =16)
Arguments
n: filter order (1 less than the length of the filter).
f: normalized frequency points, strictly increasing vector in the range [0, 1], where 1 is the Nyquist frequency. The number of elements in the vector is always a multiple of 2.
a: vector of desired amplitudes at the points specified in f. f and a must be the same length. The length must be an even number.
w: vector of weights used to adjust 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. Default: 1.
ftype: filter type, matched to one of "bandpass" (default), "differentiatior", or "hilbert".
density: determines how accurately the filter will be constructed. The minimum value is 16 (default), but higher numbers are slower to compute.
Returns
The FIR filter coefficients, a vector of length n + 1, of class Ma
Examples
## low pass filterf1 <- remez(15, c(0,0.3,0.4,1), c(1,1,0,0))freqz(f1)## band passf <- c(0,0.3,0.4,0.6,0.7,1)a <- c(0,0,1,1,0,0)b <- remez(17, f, a)hw <- freqz(b,512)plot(f, a, type ="l", xlab ="Radian Frequency (w / pi)", ylab ="Magnitude")lines(hw$w/pi, abs(hw$h), col ="red")legend("topright", legend = c("Ideal","Remez"), lty =1, col = c("black","red"))
Rabiner, L.R., McClellan, J.H., and Parks, T.W. (1975). FIR Digital Filter Design Techniques Using Weighted Chebyshev Approximations, IEEE Proceedings, vol. 63, pp. 595 - 610.