How to process all possible pairs within a vector?

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

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?
At the time no, I couldn't figure out how to generate the pair combinations. But I just got it to work. Thanks for the reply

Accedi per commentare.

Categorie

Richiesto:

il 20 Set 2016

Risposto:

il 21 Set 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by