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

fwhm

Full width at half maximum


Description

Compute peak full-width at half maximum or at another level of peak maximum for a vector or matrix.

Usage

fwhm(
  x = seq_len(length(y)),
  y,
  ref = c("max", "zero", "middle", "min", "absolute"),
  level = 0.5
)

Arguments

x

samples at which y is measured, specified as a vector. I.e., y is sampled as y[x]. Default: seq_len(length(y)).

y

signal to find the width of. If y is a matrix, widths of all columns are computed.

ref

reference. Compute the width with reference to:

"max" | "zero"

max(y)

"middle" | "min"

min(y) + max(y)

"absolute"

an absolute level of y

level

the level at which to compute the width. Default: 0.5.

Value

Full width at half maximum, returned as a vector with a length equal to the number of columns in y, or 1 in case of a vector.

Author(s)

Petr Mikulik.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

Examples

x <- seq(-pi, pi, 0.001)
y <- cos(x)
w <- fwhm(x, y)
m <- x[which.max(y)]
f <- m - w/2
t <- m + w/2
plot(x, y, type="l",
     panel.first = {
       usr <- par('usr')
       rect(f, usr[3], t, usr[4], col = rgb(0, 1, 0, 0.4), border = NA)
     })
abline(h = max(y) / 2, lty = 2, col = "gray")

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.