diagnose_filter {ravetools} | R Documentation |
Diagnose digital filter
Description
Generate frequency response plot with sample-data simulation
Usage
diagnose_filter(
b,
a,
fs,
n = 512,
whole = FALSE,
sample = stats::rnorm(n, mean = sample_signal(n), sd = 0.2),
vlines = NULL,
xlim = "auto",
cutoffs = c(-3, -6, -12)
)
Arguments
b |
the moving-average coefficients of an |
a |
the auto-regressive coefficients of an |
fs |
sampling frequency in |
n |
number of points at which to evaluate the frequency response;
default is |
whole |
whether to evaluate beyond |
sample |
sample signal of length |
vlines |
additional vertical lines (frequencies) to plot |
xlim |
frequency limit of frequency response plot; default is
|
cutoffs |
cutoff decibel powers to draw on the frequency plot, also used
to calculate the frequency limit when |
Value
Nothing
Examples
library(ravetools)
# sample rate
srate <- 500
# signal length
npts <- 1000
# band-pass
bpass <- c(1, 50)
# Nyquist
fn <- srate / 2
w <- bpass / fn
# ---- FIR filter ------------------------------------------------
order <- 160
# FIR1 is MA filter, a = 1
filter <- fir1(order, w, "pass")
diagnose_filter(
b = filter$b, a = filter$a, n = npts,
fs = srate, vlines = bpass
)
# ---- Butter filter --------------------------------------------
filter <- butter(3, w, "pass")
diagnose_filter(
b = filter$b, a = filter$a, n = npts,
fs = srate, vlines = bpass
)
[Package ravetools version 0.1.7 Index]