Learn R Programming

spectral (version 2.0)

envelope: Calculates the envelope of a band limited signal

Description

The envelope of an amplitude modulated signal can be calculated by using the Hilbert transform \(H(y)\) of the signal or the analytic signal.

Usage

envelope(y)

Arguments

y

numeric vector of the signal

Value

real valued envelope function of the signal

Details

An amplitude modulated function \(y(x) = A(x) * cos(\omega * x)\) can be demodulated as follows:

$$A(x)^2 = y(x)^2 + H(y(x))^2$$

If the signal is not band limited, strange things can happen. See the ripple at the edges in the example below. Pay attention, that the envelope is always the real part of the returned value.

Examples

Run this code
# NOT RUN {
## noisy signal with amplitude modulation
x <- seq(0,1, length.out=2e2)

# original data
y <- (abs(x-0.5))*sin(20*2*pi*x)

ye <- base::Re(envelope(y))

# plot results
plot(x,y,type="l",lwd=1,col="darkgrey",lty=2,ylab="y",main="Spectral filtering")
lines(x,ye)
legend("bottomright",c("modulated","envelope"),col=c("grey","black"),lty=c(2,1))
# }

Run the code above in your browser using DataLab