spectrum_level
Spectrum level of a signal x.
Syntax
[SL,f]=spectrum_level(x,nfft,fs,w,nov) % Matlab & Octave list <- spectrum_level(x, nfft, fs, w, nov) # R
Description
This replaces Matlab's psd function and returns units in dB re root-Hz.
Inputs
Input var | Description | Default value | |
---|---|---|---|
x | is a vector containing the signal to be processed. For signals with multiple channels, each channel should be in a column of x. | N/A | N/A |
nfft | is the length of the fft to use. Choose a power of two for fastest operation. Default value is 512. | N/A | 512 |
fs | is the sampling rate of x in Hz. Default value is 1. | Hz | 1 |
w | is the window length. The default value is nfft. If w<nfft, each segment of w samples is zero-padded to nfft. | N/A | nfft |
nov | is the number of samples to overlap each segment. The default value is half of the window length. | N/A | .5 * w |
Outputs
Output var | Description | Units |
---|---|---|
SL | is the spectrum level at each frequency in dB RMS re root-Hz. The spectrum is single-sided and extends to fs/2. The reference level is 1.0 (i.e., white noise with unit variance will have a spectrum level of 3-10*log10(fs). The 3dB is because both the negative and positive spectra are added together so that the total power in the signal is the same as the total power in the spectrum. | dB |
fs | is the vector of frequencies at which SL is calculated. | Hz |
Notes & assumptions
- Matlab: Use [ ] in any argument to access the default value or just don't specify the trailing arguments if all of the defaults are to be used
Example
Matlab & Octave
The example below uses data from the file testset1.nc. You can download it from the animaltags website's example data sets. If the file is saved in your current working directory, load it via:
testset1 = load_nc(‘testset1.nc’)
[SL,f] = spec_lev(testset1.P.data, 4, testset1.P.sampling_rate)
R
The example below uses data from the file testset1.nc. You can download it from the animaltags website's example data sets. If the file is saved in your current working directory, load it via:
testset1 <- load_nc(‘testset1.nc’)
list <- spectrum_level(x = testset1$P$data, nfft = 4, fs = testset1$P$sampling_rate)
About
bugs@animaltags.org Last modified: 27 July 2017