hilbert {gsignal}R Documentation

Hilbert transform

Description

Computes the extension of a real valued signal to an analytic signal.

Usage

hilbert(x, n = ifelse(is.vector(x), length(x), nrow(x)))

Arguments

x

Input array, specified as a vector or a matrix. In case of a matrix, the Hilbert transform of all columns is computed.

n

use an n-point FFT to compute the Hilbert transform. The input data is zero-padded or truncated to length n, as appropriate.

Details

The function returns returns a complex helical sequence, sometimes called the analytic signal, from a real data sequence. The analytic signal has a real part, which is the original data, and an imaginary part, which contains the Hilbert transform. The imaginary part is a version of the original real sequence with a 90 degrees phase shift. Sines are therefore transformed to cosines, and conversely, cosines are transformed to sines. The Hilbert-transformed series has the same amplitude and frequency content as the original sequence. The transform includes phase information that depends on the phase of the original.

Value

Analytic signal, of length n, returned as a complex vector or matrix, the real part of which contains the original signal, and the imaginary part of which contains the Hilbert transform of x.

Author(s)

Paul Kienzle, pkienzle@users.sf.net,
Peter L. Soendergaard.
Conversion to R by Geert van Boxtel, gjmvanboxtel@gmail.com

References

https://en.wikipedia.org/wiki/Hilbert_transform, https://en.wikipedia.org/wiki/Analytic_signal

Examples

## notice that the imaginary signal is phase-shifted 90 degrees
t <- seq(0, 10, length = 256)
z <- hilbert(sin(2 * pi * 0.5 * t))
plot(t, Re(z), type = "l", col="blue")
lines (t, Im(z), col = "red")
legend('topright', lty = 1, legend = c("Real", "Imag"),
       col = c("blue", "red"))

## the magnitude of the hilbert transform eliminates the carrier
t <- seq(0, 10, length = 1024)
x <- 5 * cos(0.2 * t) * sin(100 * t)
plot(t, x, type = "l", col = "green")
lines (t, abs(hilbert(x)), col = "blue")
legend('topright', lty = 1, legend = c("x", "|hilbert(x)|"),
        col = c("green", "blue"))


[Package gsignal version 0.3-5 Index]