Compare two matrices/m​eshgrid/su​rface/ model digital - distance between models - point data - 3D mesh

<<
>>
I have 3 vectors fo each surface (meshgrid). I want to compare the distance between this to surfaces. The problem is that to surfaces are not in the same position and the cells of the meshgrid are not on the same size. What i can do to obtain the correct distance between of this tow models?
surf(X,Y,Z); hold on; grid on; hold on, scatter3(NF_P(:,1),NF_P(:,2),NF_P(:,3),'filled'); surfl(X2A,Y2A,Z2A); hold on; scatter3(DD_B2(:,1),DD_B2(:,2),DD_B2(:,3)*(-1),'filled')
i want the difrence between Z and Z2A, but X and Y are difrent from X2A and Y2A.
i make Z3=Z-Z2A, bu is not correct that giv me difrences of 4 meters , that is not true, soo i dont know how to make this analyse

 Réponse acceptée

The first thing you want to do is interpolate the data from one surface to be at the x,y position of the second surface. Then compute the distance from the interpolated surface
Z_int = griddata(X,Y,Z,X2A,Y2A); %interpolate surface 1 to match x,y coordinates of surface 2
Z3 = Z_int - Z2A;
Just two more comments
  • Obviously you can think about starting from surface 2 to match the x and y of surface 1. The difference in the result should be negligible, but this depends on the data.
  • I would suggest another measure of the distance, because you can imagine that if the two surfaces cross each other you could have a distance of zero, when actually is not. I would square the difference vector and take its square root as a first attempt.
Hope this helps

6 commentaires

I understand and it is well sow, i was thinking to do what i ask because iam new in matlab. I have been starting because my thesis. Could you help me about what you suggest? I try that but i do not have success.
about your metod that is the result i have obtained...thanks a lot! </matlabcentral/answers/uploaded_files/118794/diferences_04.jpg>
do you know more ways to analyses 2 surfaces?
One of surface is based on a selection of points made with a CARIS programe (for survey Hydrographics) and the other is with my metodology selection.
Do you know how to make a surface how passe every time above all point and not in middle. Or some interpolation where i can manipulate, maybe. I asking that because i have noticed the surface do not pass exactly on the 3D point. i am rong?
I had a better look at your data, and I was surprised to see that your Z coordinates have many Nan. To have consistent results I would suggest the use of the function inpaint_nans, which interpolates the data and will replace the Nan with interpolated data (find the code here ). Of course you coulde try different interpolations methods for surfaces which are all documented in the griddata ta function. I leave here a 'base' code that makes use of the inpaint_nans to define the surface difference. You could try different methods of interpolation and see how it affects the result.
load('17may18.mat')
Z_new = inpaint_nans(Z);
Z2A_new = inpaint_nans(Z2A);
surf(X,Y,Z_new)
hold on
surf(X2A,Y2A,Z2A_new)
Z2A_int = griddata(X2A,Y2A,Z2A_new,X,Y);
surf(X,Y,Z_int)
diff = Z_new - Z2A_int;
figure(2)
surf(X,Y,diff)
In the study i am make, is not necessary or to be more specific, i can not interpolate he area outside of bounder of data. I am interest yes is delete data.
a have tryed to make a good boundaring for the data but, with boundary is not soo good.
I would like to know how to do what you suggest, if possible
  • * "I would suggest another measure of the distance, because you can imagine that if the two surfaces cross each other you could have a distance of zero, when actually is not. I would square the difference vector and take its square root as a first attempt."
I am interested in analyses and about what you say it make sense, could you help me with the scrips?
To understand better my work, that is apply on batimetric data. For products data we can not pressente data processed, in a area where was not make acquisition with a echosounder system.
My data reference for make a surface where choised for each cluster, i make groups of data and select some of them, is the selection the data more hither is what i try to select with my methodology.
in conclusion i try to select some data anda make a surface, the surface represent the topology of the area surveyed.
We have programs that do that but all it is payed and not accessible, more for hydrografic institution, like "CARIS HIPS & SHIPS". My thesis is based on creat a metodology to process the data.
The issue of cleaning the points is not trivial. I can suggest an algorithm, rather than a specific implementation, and hopefully it will be easy to implement.
  1. Construct the Mesh with the original points using the delaunayn function
  2. Determine if a query point is inside your delaunay triangulation using pointLocation function

Connectez-vous pour commenter.

Plus de réponses (1)

Hello, About what you suggest, "I would suggest another measure of the distance, because you can imagine that if the two surfaces cross each other you could have a distance of zero, when actually is not. I would square the difference vector and take its square root as a first attempt."
did you mean something like that: Zsq = sqrt(Z.^2 - Z2A.^2); that give-me error, i have the matriz with i value
(...2.3032 + 0.0000i ; NaN + 0.0000i ; NaN + 0.0000i ; NaN + 0.0000i ...)
i can´t figure what you sugest

1 commentaire

If you were to use the code above (the second comment), you could just do:
distMeasure = sqrt(norm(diff));
This will give you a single number that measures the distance of the two surfaces.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by