MATLAB: How to compare 2 sets of 3D data at the same (X,Y) coordinates by interpolating the 3rd dimension

3d datacompare datainterp2interp3?interpolationMATLABplotscatter

I have 2 sets of 3D data (X,Y,Z coordinates) which are currently in the format:
… … …
… … …
Both sets of data are the same size.
An example plot of the (X,Y) coordinates for 1 data set is shown in the image below:
Both sets of data have very similar X,Y values (but not the same) and very different Z values.
What I want to do is take my 2nd set of data, change the (X,Y) points so that they are exactly the same as data set 1, and interpolate to find what the Z coordinate will be at each of the new points for the (now shifted) data set 2.
This will allow me to calculate the difference in Z values at exactly the same X,Y location.
Thanks in advance for any help! This has had me stuck for longer than it should…

Best Answer

  • Try something like this
    model = scatteredInterpolant(x2, y2, z2);
    z2_interp = model(x1, y1);
    x2, y2, and z2 are columns of 2nd set. x1 and y1 are from the first set.