library(oce)
# Demonstrate step-function response
y <- c(rep(1, 10), rep(-1, 10))
x <- seq_along(y)
plot(x, y, type = "o", ylim = c(-1.05, 1.05))
BH <- makeFilter("blackman-harris", 11, asKernel = FALSE)
H <- makeFilter("hamming", 11, asKernel = FALSE)
yBH <- stats::filter(y, BH)
lines(x, yBH, type = "o", col = 2)
yH <- stats::filter(y, H)
lines(x, yH, type = "o", col = 3)
grid()
legend("topright",
col = 1:3, bg = "white",
legend = c("input", "Blackman Harris", "Hamming")
)
Run the code above in your browser using DataLab