View source: R/filterdiagnosis.R
diagnose_filter  R Documentation 
Generate frequency response plot with sampledata simulation
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)
)
b 
the movingaverage coefficients of an 
a 
the autoregressive 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 
Nothing
library(ravetools)
# sample rate
srate < 500
# signal length
npts < 1000
# bandpass
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
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.