/
Power spectra
Power spectra
A couple of places calculate a power spectrum. The process is as follows.
Demean
ynorm = y-mean(y);
Calculate the power spectral density with “periodogram”
fs = 1/TR;
[pxx,f] = periodogram(ynorm,[],[],fs);
Remove meaningless low frequencies
% Remove meaningless low frequencies.
minf = 1/(t(end)/2);
indCutoff = find( f < minf , 1, 'last' );
pxx(1:indCutoff) = [];
f(1:indCutoff) = [];
Calculate total power
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:
, multiple selections available,
Related content
peakdetection command line
peakdetection command line
More like this
Heart Rate Variability
Heart Rate Variability
More like this
Smoothing Timetrends
Smoothing Timetrends
More like this
peakdetection_gui
peakdetection_gui
More like this
CSPM Physiology
CSPM Physiology
More like this
Import Data into a MATLAB Variable
Import Data into a MATLAB Variable
More like this