function [ f P1 YL ] = fft2( array )
% return the fft of an array
a = array - mean(array);
Fs = 500;
T = 1/Fs;
L = length(array);
t = (0:L-1)*T;

% Let's apply a window.
w = hamming(L);
wa(L) = 0;
for i = 1:L
wa(i) = w(i)*a(i);
end

Y = fft( wa );
YL = Y/L;
P2 = abs( YL );
P1 = P2( 1:fix(L/2)+1 );
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:fix(L/2))/L;