%find the coefficient and phase of the fundamental of the data;
%phase is defined as data = coef * cos(t-phase) .... t runs from 0:2*pi
function [coef, phase] = fund2_3d(data)

[NT, NN,N]=size(data);
display(['time dimension is ' num2str(NT)]) 

for nn=1:NN;
    for n=1:N
        H=fft(data(:,nn,n));
            coef(nn,n,1)=abs(H(2)/(NT/2));
            phase(nn,n,1)=angle(H(2));
    end
end
