How can I find distances between 100 points such that I have a set of distances of each point from rest of the points.
1 view (last 30 days)
Show older comments
Tamoor Shafique on 2 Jan 2021
Commented: Tamoor Shafique on 3 Jan 2021
I have distributed 100 points randomly in a 100x100x100 m3 3D space. I want to find distance of each point from rest of 99 points such that I have a distance set of 4950 different values. so the distance of 1st node from resy 99 nodes and then distance of 2nd node from rest 98 nodes and so on.
I cannot change the style of the code since I have values saved in these variables.
I have following code:
if (i==j && j==k & k==i) % so I dont get 100x100x100 different values and only 100 values with x,y,z coordinates.
S(i).xd=(1,1)*xm; %I cannot change this
Ameer Hamza on 2 Jan 2021
Just use pdist() function
X = [..]; % create 100x3 matrix
dists = pdist(X)
Find more on Solver Outputs and Iterative Display 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!