remez {gsignal}R Documentation

Parks-McClellan optimal FIR filter design

Description

Parks-McClellan optimal FIR filter design using the Remez exchange algorithm.

Usage

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.

Value

The FIR filter coefficients, a vector of length n + 1, of class Ma

Author(s)

Jake Janovetz, janovetz@uiuc.edu,
Paul Kienzle, pkienzle@users.sf.net,
Kai Habel, kahacjde@linux.zrz.tu-berlin.de.
Conversion to R Tom Short
adapted by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

References

https://en.wikipedia.org/wiki/Fir_filter

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.
https://en.wikipedia.org/wiki/Parks-McClellan_filter_design_algorithm

See Also

Ma, filter, fftfilt, fir1

Examples

## low pass filter
f1 <- remez(15, c(0, 0.3, 0.4, 1), c(1, 1, 0, 0))
freqz(f1)

## band pass
f <- 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"))


[Package gsignal version 0.3-5 Index]