How to process all possible pairs within a vector?
Ältere Kommentare anzeigen
I have the vector [1,2,3,7,9,10,12,13,14,15,17,20] and I need to process all possible pair combinations within the vector. Each pair has a value associated with it that is stored in a matrix and I need to find the minimal sum of values. For example combination one is pairs (1,2)(3,7)(9,10)(12,13)(14,15)(17,20). If the attached pair values were (1,2,3,4,5,6) the sum of values for this combination would be 21.
I know there are 10,395 pair combinations given the length of 12 values. Is there an easy way to process this with indexing or a function I'm not aware of that would generate the pairs? I know how to handle the minimization of values sum portion of the problem.
2 Kommentare
Image Analyst
am 20 Sep. 2016
Do you have all the 10,395 pair combinations stored in a 6 by 2 by 10,395 array already? Or do you still need to figure that out?
Chuck
am 21 Sep. 2016
Antworten (1)
KSSV
am 21 Sep. 2016
0 Stimmen
doc nchoosek
Kategorien
Mehr zu Matrices and Arrays finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!