Hi,
I have 3 xyz data files (each contains longitude(z), latitude(y), and the water depth(z)). For my assignments, I have to combine these 3 xyz data files together to create a new bathymetry. I have tried the following codes, but matlab just crashed everytime i run it.
%%COMBINE 2014 XYZ DATA FILES
clear all; clca=load('bs_09092014_soundings-mean.pts');b=load('bs_09092014_soundings_shoalest.pts');c=load('bs_10092014-levels.pts');% FIND THE MIN AND MAX AMONG THE 3 DATA FILES
% FIND X MIN
if ((min(a(:,1))>min(b(:,1))) && (min(a(:,1))>min(c(:,1)))) xmin=min(a(:,1));else if ((min(b(:,1))>min(a(:,1))) && (min(b(:,1))>min(c(:,1)))) xmin=min(b(:,1)); else xmin=min(c(:,1)); endend% FIND X MAX
if ((max(a(:,1))<max(b(:,1))) && (max(a(:,1))<max(c(:,1)))) xmax=max(a(:,1));else if ((max(b(:,1))<max(a(:,1))) && (max(b(:,1))<max(c(:,1)))) xmax=max(b(:,1)); else xmax=max(c(:,1)); endend% FIND Y MIN
if ((min(a(:,2))>min(b(:,2))) && (min(a(:,2))>min(c(:,2)))) ymin=min(a(:,2));else if ((min(b(:,2))>min(a(:,2))) && (min(b(:,2))>min(c(:,2)))) ymin=min(b(:,2)); else ymin=min(c(:,2)); endend% FIND Y MAX
if ((max(a(:,2))<max(b(:,2))) && (max(a(:,2))>max(c(:,2)))) ymax=max(a(:,2));else if ((max(b(:,2))>max(a(:,2))) && (max(b(:,2))>max(c(:,2)))) ymax=max(b(:,2)); else ymax=max(c(:,2)); endend% FIND THE INDICES BETWEEN XY MIN AND MAX, TO CREATE A NEW MATRIX THAT CONSISTS OF THE INTERSECTIONAL AREA OF ALL 3 XYZ FILES
aInd=find(a(:,1)>xmin & a(:,1)<xmax & a(:,2)>ymin & a(:,2)<ymax);xa=a(aInd,1);ya=a(aInd,2);za=a(aInd,3);bInd=find(b(:,1)>xmin & b(:,1)<xmax & b(:,2)>ymin & b(:,2)<ymax);xb=b(bInd,1);yb=b(bInd,2);zb=b(bInd,3);cInd=find(c(:,1)>xmin & c(:,1)<xmax & c(:,2)>ymin & c(:,2)<ymax);xc=c(cInd,1);yc=c(cInd,2);zc=c(cInd,3);xstep=linspace(xmin,xmax,1000);ystep=linspace(ymin,ymax,1000);[xia yia]=meshgrid(xstep,ystep);zia=griddata(xa,ya,za,xia,yia);[xib yib]=meshgrid(xstep,ystep);zib=griddata(xb,yb,zb,xib,yib);[xic yic]=meshgrid(xstep,ystep)'zic=griddata(xc,yc,zc,xic,yic);pcolor(xia,yia,zia);shading interphold onpcolor(xib,yib,zib);shading interphold onpcolor(xic,yic,zic);shading interphold off
Thanks, Eve
Best Answer