フィルターのクリア

summations of combinations of elements, one from each column of a 2D matrix, in small to large order

2 ビュー (過去 30 日間)
I have a 2D numerical matrix of size 1000 by 8: [0 a1 a2 a3 a4 ... a999; 0 b1 b2 b3 b4 ... b999; ... ; 0 h1 h2 h3 h4 ... h999]' , where each column is in ascending order, i.e., 0<a1<a2<a3<...<a999, etc. However, I don't know how a1 compares to b1, or c1, etc. For example, b100 could be smaller than a1.
Now, I would like to find the first 1000,000 combinations of 8 elements, each coming from a column, that have the smallest summation values. For each combination, I would like to retain the row and column indices of each element as well.
Can anyone help me with the problem? Thank you very much for your help in advance.
  1 件のコメント
Mathieu NOE
Mathieu NOE 2024 年 6 月 10 日
seems to me that because your 8 columns of data contains sorted values , the first combination of 8 values (each one picked in a separate column) is the first row of the 8 cols.
if now you retrieve these data for the next iteration, then your second combination is the second row of the same 8 cols and so forth .
so the first N combinations giving you the smallest sum is the N first rows (and do the sum along the cols direction)

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

回答 (1 件)

Prateekshya
Prateekshya 2024 年 7 月 8 日
編集済み: Prateekshya 2024 年 7 月 8 日
Hi Jianwei,
I understand that you want to retrieve the first 1000000 combinations of 8 elements coming from each column. You may use the MATLAB function "nchoosek" for this purpose. Please follow this link to know more about it:
I hope it helps!
Thank you.

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by