How to process all possible pairs within a vector?
Mostra commenti meno recenti
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 Commenti
Image Analyst
il 20 Set 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
il 21 Set 2016
Risposte (1)
KSSV
il 21 Set 2016
0 voti
doc nchoosek
Categorie
Scopri di più su Matrices and Arrays in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!