%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] = fund_4d(data)

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

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