Learn R Programming

rsleep (version 1.0.12)

bandpass: Bandpass Filter Function

Description

This function applies a bandpass filter to a signal. It first normalizes the high and low frequencies based on the Nyquist frequency, then creates a Butterworth filter using the `signal::butter` function, and finally applies the filter to the signal using `signal::filtfilt`.

Usage

bandpass(x, high, low, sRate, order = 5)

Value

A numeric vector representing the filtered signal.

Arguments

x

A numeric vector representing the signal to be filtered.

high

The high cutoff frequency for the bandpass filter.

low

The low cutoff frequency for the bandpass filter.

sRate

The sampling rate of the signal.

order

The order of the Butterworth filter, defaulting to 5.

References

If applicable, add references here.

See Also

butter, filtfilt

Examples

Run this code
sample_signal <- sin(seq(0, 10, length.out = 1000))
filtered_signal <- bandpass(sample_signal, high = 0.3, low = 0.1, sRate = 100)

Run the code above in your browser using DataLab