MATLAB: Compute 3D distance between 32 points

3ddistance3d

I have encountered the following problem: I have to divide a square with L=12 in 4×4 smallers squares and find the center point of each small square. This will represent surface 1 and then i have to do the exact thing for surface 2.
Now, i have to compute the distances between each center of surface 1 and each center of the surface 2. So i will have a total of 256 distances. How do i do that ? Check out the photos.

Best Answer

To find the distance from every one of 16 points to every one of another set of 16 points would give 16 * 16 = 256 distances. You can get these out in a 16 by 16 2-D array using pdist2(). Attach your data (2 lists of points) in a .mat file if you need more help.
distances = pdist2(xySet1, xySet2);
Related Question