pwelch {PAMmisc} | R Documentation |
Estimate Power Spectral Density Using Welch's Method
Description
Estimates the power spectral density (PSD) of an input signal using Welch's method. This should function similarly to the Matlab function pwelch, but results may not be identical. Breaks the input signal into (usually) overlapping frames and averages the resulting PSD estimates
Usage
pwelch(
x,
nfft,
noverlap = 0,
sr = NULL,
window = NULL,
demean = c("long", "short", "none"),
channel = 1
)
Arguments
x |
input signal, either a numeric vector, Wave,
WaveMC, or |
nfft |
length of FFT window to use for individual frames |
noverlap |
number of samples each frame should overlap |
sr |
sample rate of data, only necessary if |
window |
window to apply, must be a vector of length |
demean |
method of demeaning the signal, one of |
channel |
channel number to analyse, ignored if |
Value
returns a list with items spec
, the PSD estimate of the
input signal, and freq
, the frequency values (Hz) at
each value of spec
Author(s)
Taiki Sakai taiki.sakai@noaa.gov
Examples
# wav example is synthetic echolocation clicks at 4kHz
wavFile <- system.file('extdata/testWav.wav', package='PAMmisc')
psd <- pwelch(wavFile, nfft=1e3, noverlap=500, demean='long')
plot(x=psd$freq, y=10*log10(psd$spec), type='l')