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 件のコメント

Image Analyst
Image Analyst 2016 年 9 月 20 日
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
Chuck 2016 年 9 月 21 日
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

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2016 年 9 月 21 日

0 投票

doc nchoosek

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

タグ

質問済み:

2016 年 9 月 20 日

回答済み:

2016 年 9 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by