All possible pairs in a vector
Show older comments
Hi, and thank you in advance for taking the time to read this. Is there a quick way to get all possible pairs from a vector? For example A=[1 2 3 4 5]; [1 2], [1 3], [1 4], [1 5], [2 3], [2 4], [2 5], [3 4], [3 5], [4 5]. I think I can get that with 2 for loops but I would like to know if there's a know faction for that.
Thank you
Accepted Answer
More Answers (1)
David Fletcher
on 15 Apr 2018
nchoosek(A,2)
Categories
Find more on Matrix Indexing 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!