range=67:67:67*200;
c=1; %initialize counter
files=dir(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\frances\data\modified\tr20dd\*dat']);
x=[];
y=[];
z=[];
vel=[];

for fil=1:2:10%length(files)
    sweepfile=files(fil).name;
    data=load(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\frances\data\modified\tr20dd\',sweepfile]);
    azimuth=data(length(data),:); %azimuth is a row matrix
    ppi=data(1:length(data)-1,:);
    el=str2num(sweepfile(30:32));
    height=range*sin(deg2rad(el));
    
    az=ones(max(size(range)),1)*azimuth;
    rg=range'*ones(1,max(size(azimuth)));
    zz=height'*ones(1,max(size(azimuth)));
    [li,col]=size(az);
    L=li*col;
    
   [h,i,j]=pol2cart(deg2rad(az),rg,zz);
    x_temp=reshape(h,L,1);
    y_temp=reshape(i,L,1);
    z_temp=reshape(j,L,1);
    vel_temp=reshape(ppi(1:li,:),L,1);
    
    x=[x;x_temp];
    y=[y;y_temp];
    z=[z;z_temp];
    vel=[vel;vel_temp];

   
    
end
u_NaN=find(~isnan(vel));
x=x(u_NaN);
y=y(u_NaN);
z=z(u_NaN);
vel=vel(u_NaN);
u=find(x>=-10000 & x<=10000 & y >=-10000 & y<=10000 & z <=300);
x2=x(u);
y2=y(u);
z2=z(u);
vel2=vel(u);
 [xi,yi,zi]=meshgrid(-10000:100:10000,-10000:100:10000,0:50:300);
 clear('data','u_NaN','h','i','j','x_temp','y_temp','z_temp','ppi','az','rg','zz')
   w=griddata3(x2,y2,z2,vel2,xi,yi,zi);








