%acorr.m: computes the autocorrelation function of a 1-D data vector
%            
%            a      = 1-D data vector
%            maxlag = maximum lag          
%            usage: z=autocorr (a,maxlag);
function [s]=acorr(a,maxlag)
nn=length(a);
a1=(a-mean(a))/std(a);
for i=1:maxlag;
   b1=(a1(1:nn-i+1)-mean(a1(1:nn-i+1)))/std(a1(1:nn-i+1));
   b2=(a1(i:nn)-mean(a1(i:nn)))/std(a1(i:nn));
   s(i)=mean(b1.*b2);
end

   
      
