close all
clear all
% ***** read u
load utime_backstep.dat
utime=utime_backstep;

u1=utime(:,1); %x=3.3, y=0.037
u2=utime(:,2); %x=8.7, y=0.037
u3=utime(:,3); %x=18.7, y=0.037
u4=utime(:,4); %x=3.3, y=0.85
u5=utime(:,5); %x=8.7, y=0.85
u6=utime(:,6); %x=18.7, y=0.85
u7=utime(:,7); %x=-3.94, y=1.017
v1=utime(:,8); %x=3.3, y=0.85
v2=utime(:,9); %x=8.7, y=0.85
v3=utime(:,10); %x=18.7, y=0.85
t=utime(:,11);  % time


n=length(u1);

imax=700
%for i=1:imax
   %two_a(i)=exp(-t(i)/tturb);
%end

u1_fluct=u1-mean(u1);
u2_fluct=u2-mean(u2);
v1_fluct=v1-mean(v1);

% check of Octave or Malab
if exist('OCTAVE_VERSION');
  result = true;
else
  result = false
end
if result 
% octave
%two=xcorr(u_fluct,imax,'coeff');
   two_uu_1_mat=xcorr(u1_fluct,imax,'coeff');
   two_uu_2_mat=xcorr(u2_fluct,imax,'coeff');
   
   two_vv_1_mat=xcorr(v1_fluct,imax,'coeff');
else
% Matlab

   two_uu_1_mat=autocorr(u1_fluct,imax);
   two_uu_2_mat=autocorr(u2_fluct,imax);
   
   two_vv_1_mat=autocorr(v1_fluct,imax);
end

dt=t(1);
int_T_1=trapz(two_uu_1_mat)*dt;

dt=t(1);
int_T_1=trapz(two_uu_1_mat)*dt;

%%%%%%%%%%%%%%%% plotting section %%%%%%%%%%%%%%%%%%%%%%%%%%
% plot autocorr
figure(5)
if result 
% octave 
   plot(t(1:imax+1),two_uu_1_mat(imax+1:end))
else
% matlab
   plot(t(1:imax),two_uu_1_mat(1:imax),'linewidth',2)
end
hold
xlabel('t')
ylabel('u')
handle=gca
set(handle,'fontsize',[20])
print two_time_corr_backstep_1-4.ps -deps
