medfilt1: Median filter

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/filter.R

Description

Deprecated! Performs an n-point running median. For Matlab/Octave compatibility.

Usage

1
2
3
4
5
6
medfilt1(x, n = 3, ...)

MedianFilter(n = 3)

## S3 method for class 'MedianFilter'
filter(filt, x, ...)

Arguments

x

signal to be filtered.

n

size of window on which to perform the median.

filt

filter to apply to the signal.

...

additional arguments passed to runmed.

Details

medfilt1 is a wrapper for runmed.

Value

For medfilt1, the filtered signal of length(x).

For MedianFilter, a class of “MedianFilter” that can be used with filter to apply a median filter to a signal.

Author(s)

Tom Short.

References

https://en.wikipedia.org/wiki/Median_filter

Octave Forge https://octave.sourceforge.io/

See Also

runmed, median, filter

Examples

1
2
3
4
5
6
7
t <- seq(0, 1, len=100)                            # 1 second sample
x <- sin(2*pi*t*2.3) + 0.25*rlnorm(length(t), 0.5) # 2.3 Hz sinusoid+noise
plot(t, x, type = "l")
# 3-point filter
lines(t, medfilt1(x), col="red", lwd=2) 
# 7-point filter
lines(t, filter(MedianFilter(7), x), col = "blue", lwd=2) # another way to call it

Example output

Attaching package: 'signal'

The following objects are masked from 'package:stats':

    filter, poly

Warning message:
'medfilt1' is deprecated. Use 'runmed' of the 'stats' package instead. 

signal documentation built on May 25, 2021, 9:06 a.m.

Related to medfilt1 in signal...