How to process all possible pairs within a vector?
Mostrar comentarios más antiguos
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 comentarios
Image Analyst
el 20 de Sept. de 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
el 21 de Sept. de 2016
Respuestas (1)
KSSV
el 21 de Sept. de 2016
0 votos
doc nchoosek
Categorías
Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!