Learn R Programming

signal (version 1.8-0)

fftfilt: Filters with an FIR filter using the FFT

Description

Filters with an FIR filter using the FFT.

Usage

fftfilt(b, x, n = NULL)

FftFilter(b, n)

# S3 method for FftFilter filter(filt, x, ...)

Value

For fftfilt, the filtered signal, the same length as the input signal x.

For FftFilter, a filter of class FftFilter that can be used with filter.

Arguments

b

the moving-average (MA) coefficients of an FIR filter.

x

the input signal to be filtered.

n

if given, the length of the FFT window for the overlap-add method.

filt

filter to apply to the signal.

...

additional arguments (ignored).

Author

Original Octave version by Kurt Hornik and John W. Eaton. Conversion to R by Tom Short.

Details

If n is not specified explicitly, we do not use the overlap-add method at all because loops are really slow. Otherwise, we only ensure that the number of points in the FFT is the smallest power of two larger than n and length(b).

References

Octave Forge https://octave.sourceforge.io/

See Also

Ma, filter, fft, filtfilt

Examples

Run this code
t <- seq(0, 1, len = 100)                     # 1 second sample
x <- sin(2*pi*t*2.3) + 0.25*rnorm(length(t))  # 2.3 Hz sinusoid+noise
z <- fftfilt(rep(1, 10)/10, x) # apply 10-point averaging filter
plot(t, x, type = "l")
lines(t, z, col = "red")

Run the code above in your browser using DataLab