How do you get all pairs without double counting?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Given, say, 10 numbers, how do you get all possible pairs between the numbers without double counting? Order doesn't matter, so 1-3 is the same as 3-1. How would you do this with for loops vs. vectorized? Is there a difference in performance between the two?
0 Kommentare
Antworten (1)
Voss
am 16 Jul. 2022
Here's one way:
ten_numbers = 1:10;
all_pairs = nchoosek(ten_numbers,2);
disp(all_pairs);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!