How do I find the intersection area of two bathymetry grid?

2 views (last 30 days)
Hi,
I have two bathymetry with different sizes.
My task is to
FIRST, find the intersected area of these two bathymetry.
p/s: Please find attached image for the illustration of my task in case I'm bad at describing it. I need to find the minimum and maximum x and y values that intersected, and from there, I've got values to define my range. Next, the shaded area in the picture contains z-values from both files that I need to subtract in order to see the difference in water level.
SECOND, define a new range and spacing
THIRD, subtract my z-values within the intersected area.
FOURTH, plot
So, I'm stuck at the subtraction part because I have different size matrices.
The following is my code
a=load('com_2014.txt');
b=load('com_2011test2.txt');
% FIND THE XY MIN AND MAX VALUES OF EACH VARIABLE
xminmin=[min(a(:,1));min(b(:,1))];
xmin=max(xminmin);
% X MAX
xmaxmax=[max(a(:,1));max(b(:,1))];
xmax=min(xmaxmax);
% Y MIN
yminmin=[min(a(:,2));min(b(:,2))];
ymin=max(yminmin);
% Y MAX
ymaxmax=[max(a(:,2));max(b(:,2))];
ymax=max(ymaxmax);
% FIND THE INDICES BETWEEN XY MIN AND MAX
% FOR MATRIX a
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);
% FOR MATRIX b
bInd=find((b(:,1)>=xmin) & (b(:,1)<=xmax) & (b(:,2)>=ymin) & (a(:,2)<=ymax));
xb=b(bInd,1);
yb=b(bInd,2);
zb=b(bInd,3);
And I'm stuck after this. HELP! URGENT!!!
Thanks!!!!!!!!
  1 Comment
Geoff Hayes
Geoff Hayes on 23 Oct 2014
eevee - you may need to describe (or attach) your two data files. Are they simply just three columns of data with the first and second columns corresponding to the x and y coordinates respectively (and the third column the water level)? Are these coordinates integers or real numbers? (If the former you may be able to create matrices from your data where the (x,y) element of the matrix is the z (water level) value.)

Sign in to comment.

Answers (0)

Categories

Find more on Automotive in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!