function [ P,freq ] = dbfft( t,h,fmax,npt)
%returns normalized spectral power from a simple periodogram and matching
%frequency array
%   
%calculate frequency array

Nyquist=0.5/abs((t(2)-t(1)));
f=linspace(0,Nyquist,npt/2);
num=round(npt/2*fmax/Nyquist);
freq=f(1:num);

%calculate FFT and Power after padding
H=fft(detrend(h),npt);
P=H.*conj(H);

%normalize to unit mean power
P=P/mean(P(1:npt/2));
P=P(1:num);

end

