function y = domfreq(x)

%   Y = DOMFREQ(X) calculates the frequency Y of the highest 
%   peak (between 0 and 15 Hz) in the 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,128,200);
f15 = round(15/200*512)+1;
[mx,ix] = max(xspec(1:f15));
y = f(ix);

return