%function [corre]=tracking(corre)
Vmax=35;
hurricane='frances';
rep='meanless\temp\filtered\2000\gridded_data\';
rep2='temp\azimuth time\';
files=dir(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\',hurricane,'\data\modified\',rep,'*.mat']); 
first_file=1:length(files)-3;
sx=1; % -1 si l'image a t2 doit etre translate  negativement sur l'axe x pour coincider avec l'image a t1
sy=1;
min_x=2500;
max_x=4500;
min_y=1000;
max_y=2500;
for ref=1%:length(first_file)
    ref
    fichier_1=first_file(ref);
    sweepfile=files(fichier_1).name;
    
    
    pas=25;
    load(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\',hurricane,'\data\modified\',rep,sweepfile]);%output :x,y,image1
    u=find( x >= min_x & x <= max_x);
    v=find(y >= min_y & y <= max_y);
    template=image1(u,v);
    u_NaN=find(isnan(template));
    template(u_NaN)=-9999;
    [m,n]=size(template);
    load(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\',hurricane,'\data\modified\',rep2,sweepfile]);
    t1=find_az_time(min_x,max_x,min_y,max_y,az,time_ray)
%     pcolor(template')
%      shading flat
%         caxis([-4 4]);
    for fil=fichier_1+1:fichier_1+3
        sweepfile=files(fil).name;
        
        
        load(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\',hurricane,'\data\modified\',rep,sweepfile]);
        load(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\',hurricane,'\data\modified\',rep2,sweepfile]);
        
        if (fil-ref)==1
            delta_t=20;
        elseif (fil-ref)==2
            delta_t=35;
        elseif (fil-ref)==3
            delta_t=50;
        end
        max_delta=delta_t*Vmax;
        if sx > 0
            limit_sup_x=min((min_x - min(x)),max_delta);
        elseif sx < 0
            limit_sup_x = min((max(x)- max_x),max_delta);
        end
        if sy > 0
            limit_sup_y=min((min_y - min(y)),max_delta);
        elseif sy < 0
            limit_sup_y = min((max(y) - max_y),max_delta) ;
        end
        
        %delta_x=sx*(pas:pas:limit_sup_x);
        delta_x=-200:25:200;
        delta_y=sy*(pas:pas:limit_sup_y);
        for i=1:length(delta_x)
            for j=1:length(delta_y)
                x_trans=x+delta_x(i);
                y_trans=y+delta_y(j);
                u=find( x_trans >=min_x & x_trans <=max_x);
                v=find(y_trans>=min_y & y_trans<= max_y);
                template2=image1(u,v);
                u_NaN=find(isnan(template2));
                template2(u_NaN)=-9999;
                c=normxcorr2(template,template2);
                coeff_matrix(i,j)=c(m,n);
                
            end
        end
        
        temp=max(max(coeff_matrix))
        [i_trans,j_trans]=find(coeff_matrix==temp);
        x_trans=x+delta_x(i_trans);
        y_trans=y+delta_y(j_trans);
        u=find( x_trans >=min_x & x_trans <=max_x);
        v=find(y_trans>=min_y & y_trans<= max_y);
        x2=x(u);
        y2=y(v);
%         figure
%         pcolor(image1(u,v)')
%         shading flat
%         caxis([-4 4]);
        t2=find_az_time(min(x2),max(x2),min(y2),max(y2),az,time_ray)
        corre(fichier_1).r(fil)=temp
        corre(fichier_1).v_x(fil)=-delta_x(i_trans);
        corre(fichier_1).v_y(fil)=-delta_y(j_trans);
        corre(fichier_1).delta_t(fil)=etime(t2,t1);
%         figure
%           pcolor(coeff_matrix')
%         shading flat
%         caxis([-1 1]);
              %pause
%              yyy=1;
%          close all
        
        clear('image1','coeff_matrix')
    end
        %save(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\',hurricane,'\data\modified\meanless\temp\filtered\2000\corre4.mat'],'corre');


end
