I will choose the first coordinate and calculate the distance to other coordinates by using the above equation. In the second step I will take the second coordinate and calculate the distance to other coordinates. since the distance between first one and second one is already calculated there is no need to do it again. In this way I have to find the distance between all coordinates. Can anyone help me.

2 Answers
2

Essentially you have a number of points, lets say 1 to 4, and you want the distance corresponding to every subset containing two points, so first lets calculate the indexes using SubSets[]

Subsets[Range[4], {2}]

{{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}}

This gives you all the different distances to calculate, now to carry this out, we simply create a function to return the distance and map it over these subsets (naturally using the actual length of our inputs.

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.