%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(data)
[NN, NT]=size(data);
if NT == 1;
    data=data';
    [NN, NT]=size(data);
end

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