function y = pow4to6(x)

%   Y = POW4TO6(X) calculates the energy in the 4 to 6 Hz range as a
%   proportion of the total energy between 0 and 15 Hz in a smoothed
%   spectrum of a signal vector X.
%  
%   The spectrum is estimated using the PSD (Power Spectral Density)
%   estimate: Welch's averaged, modified periodogram method.
% 

%   Copyright 2003
%   Centre for Nonlinear Dynamics in Physiology and Medicine

[xspec,f] = psd(x,512,200);
f15 = round(15/200*512)+1;
f4 = round(4/200*512)+1;
f6 = round(6/200*512)+1;
y = sum(xspec(f4:f6)) / sum(xspec(1:f15));

return
