## noise suppression
fs <- 100
t <- seq(0, 1, 1/fs)
x <- sin(2 * pi * t * 3) + 0.25 * sin(2 * pi * t * 40)
plot(t, x, type = "l", xlab = "", ylab = "")
y <- medfilt1(x, 11)
lines (t, y, col = "red")
legend("topright", c("Original", "Filtered"), lty = 1, col = 1:2)
Run the code above in your browser using DataLab