Combinations of matrix rows

1 view (last 30 days)
Amy Diekmann
Amy Diekmann on 17 Sep 2017
Commented: KSSV on 19 Sep 2017
I have a matrix of x and y coordinates of points. I used nchoosek to figure out how many different combinations I can have, but how do I get MATLAB to do those combinations? A=[x coord. y coord.] =[1 2; 2 2;3 5;4 7;7 1] I have 5 points and I need to determine the minimum distance between all points (i.e. between points 1 and 2, between points 1 and 3, between points 1 and 5, between points 2 and 3, etc).

Accepted Answer

KSSV
KSSV on 18 Sep 2017
You need not to see for possible combinations.....read about the function pdist. It gives distance among all possible points.
  2 Comments
KSSV
KSSV on 19 Sep 2017
Amy Diekmann commented: Is there a way to determine which two coordinates gives the smallest distance? Thanks!
KSSV
KSSV on 19 Sep 2017
Yes...why not.....check the min of the matrix...and it's indices should give you the concerned points..

Sign in to comment.

More Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox 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!