Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fir2

FIR filter generation


Description

FIR filter coefficients for a filter with the given order and frequency cutoffs.

Usage

fir2(n, f, m, grid_n = 512, ramp_n = grid_n/20, window = hamming(n + 1))

Arguments

n

order of the filter (1 less than the length of the filter)

f

band edges, strictly increasing vector in the range [0, 1] where 1 is the Nyquist frequency. The first element must be 0 and the last element must be 1. If elements are identical, it indicates a jump in frequency response.

m

magnitude at band edges, a vector of length(f).

grid_n

length of ideal frequency response function defaults to 512, should be a power of 2 bigger than n.

ramp_n

transition width for jumps in filter response defaults to grid_n/20. A wider ramp gives wider transitions but has better stopband characteristics.

window

smoothing window. The returned filter is the same shape as the smoothing window.

Value

The FIR filter coefficients, an array of length(n+1), of class Ma.

Author(s)

Original Octave version by Paul Kienzle, pkienzle@user.sf.net. Conversion to R by Tom Short.

References

Octave Forge http://octave.sf.net

See Also

Examples

f <- c(0, 0.3, 0.3, 0.6, 0.6, 1)
m <- c(0, 0, 1, 1/2, 0, 0)
fh <- freqz(fir2(100, f, m))
op <- par(mfrow = c(1, 2))
plot(f, m, type = "b", ylab = "magnitude", xlab = "Frequency")
lines(fh$f / pi, abs(fh$h), col = "blue")
# plot in dB:
plot(f, 20*log10(m+1e-5), type = "b", ylab = "dB", xlab = "Frequency")
lines(fh$f / pi, 20*log10(abs(fh$h)), col = "blue")
par(op)

signal

Signal Processing

v0.7-6
GPL-2
Authors
Uwe Ligges [aut, cre] (new maintainer), Tom Short [aut] (port to R), Paul Kienzle [aut] (majority of the original sources), Sarah Schnackenberg [ctb] (various test cases and bug fixes), David Billinghurst [ctb], Hans-Werner Borchers [ctb], Andre Carezia [ctb], Pascal Dupuis [ctb], John W. Eaton [ctb], E. Farhi [ctb], Kai Habel [ctb], Kurt Hornik [ctb], Sebastian Krey [ctb], Bill Lash [ctb], Friedrich Leisch [ctb], Olaf Mersmann [ctb], Paulo Neis [ctb], Jaakko Ruohio [ctb], Julius O. Smith III [ctb], Doug Stewart [ctb], Andreas Weingessel [ctb]
Initial release
2015-07-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.