Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

movingrms

Moving Root Mean Square


Description

Compute the moving root mean square (RMS) of the input signal.

Usage

movingrms(x, width = 0.1, rc = 0.001, fs = 1)

Arguments

x

Input signal, specified as a numeric vector or matrix. In case of a matrix, the function operates along the columns

width

width of the sigmoid window, in units relative to fs. Default: 0.1

rc

Rise time (time constant) of the sigmoid window, in units relative to fs. Default: 1e-3

fs

Sampling frequency. Default: 1

Details

The signal is convoluted against a sigmoid window of width w and risetime rc. The units of these parameters are relative to the value of the sampling frequency given in fs.

Value

A list containing 2 variables:

rmsx

Output signal with the same dimensions as x

w

Window, returned as a vector

Author(s)

Juan Pablo Carbajal, carbajal@ifi.uzh.ch.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

See Also

Examples

N <- 128
t <- seq(0, 1, length.out = N)
x <- sigmoid_train(t, c(0.4, Inf), 1e-2)$y * (2 * runif(length(t)) - 1)
fs <- 1 / diff(t[1:2])
width <- 0.05
rc <- 5e-3
ret <- movingrms(as.numeric(scale(x)), width, rc, fs)
plot(t, x, type = "l", col = "red", xlab = "", ylab = "")
lines(t, ret$rmsx, lwd = 4, col = "black")
polygon(c(0, t, length(t)), c(0, ret$rmsx, 0), col = "blue")
lines (t, ret$w, lwd = 2, col = "green")
legend("topleft", c("data", "window", "movingrms"), lty = 1,
       col = c("red", "green", "blue"))

gsignal

Signal Processing

v0.3-1
GPL-3
Authors
Geert van Boxtel [aut, cre] (Maintainer), Tom Short [aut] (Author of 'signal' package), Paul Kienzle [aut] (Majority of the original sources), Ben Abbott [ctb], Juan Aguado [ctb], Muthiah Annamalai [ctb], Leonardo Araujo [ctb], William Asquith [ctb], David Bateman [ctb], David Billinghurst [ctb], Juan Pablo Carbajal [ctb], André Carezia [ctb], Vincent Cautaerts [ctb], Eric Chassande-Mottin [ctb], Luca Citi [ctb], Dave Cogdell [ctb], Carlo de Falco [ctb], Carne Draug [ctb], Pascal Dupuis [ctb], John W. Eaton [ctb], R.G.H Eschauzier [ctb], Andrew Fitting [ctb], Alan J. Greenberger [ctb], Mike Gross [ctb], Daniel Gunyan [ctb], Kai Habel [ctb], Kurt Hornik [ctb], Jake Janovetz [ctb], Alexander Klein [ctb], Peter V. Lanspeary [ctb], Bill Lash [ctb], Friedrich Leissh [ctb], Laurent S. Mazet [ctb], Mike Miller [ctb], Petr Mikulik [ctb], Paolo Neis [ctb], Georgios Ouzounis [ctb], Sylvain Pelissier [ctb], Francesco Potortì [ctb], Charles Praplan [ctb], Lukas F. Reichlin [ctb], Tony Richardson [ctb], Asbjorn Sabo [ctb], Thomas Sailer [ctb], Rolf Schirmacher [ctb], Rolf Schirmacher [ctb], Ivan Selesnick [ctb], Julius O. Smith III [ctb], Peter L. Soendergaard [ctb], Quentin Spencer [ctb], Doug Stewart [ctb], P. Sudeepam [ctb], Stefan van der Walt [ctb], Andreas Weber [ctb], P. Sudeepam [ctb], Andreas Weingessel [ctb]
Initial release
2021-05-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.