Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A couple of places calculate a power spectrum. The process is as follows.

For the input timeseries y:

Demean

Code Block
languagematlab
 ynorm = y-mean(y);

Calculate the power spectral density with “periodogram”

Code Block
fs = 1/TR;
[pxx,f] = periodogram(ynorm,[],[],fs);

Remove meaningless low frequencies

Code Block
% Remove meaningless low frequencies.
minf = 1/(t(end)/2);
indCutoff = find( f < minf , 1, 'last' );

pxx(1:indCutoff) = [];
f(1:indCutoff) = [];

Calculate total power

Code Block
    powerTotal = bandpower( pxx, f, 'psd' );

p = bandpower(pxx,f,'psd') returns the average power computed by integrating the power spectral density (PSD) estimate, pxx. The integral is approximated by the rectangle method. The input, f, is a vector of frequencies corresponding to the PSD estimates in pxx. The 'psd' option indicates that the input is a PSD estimate and not time series data.

For the input timeseries y: