summations of combinations of elements, one from each column of a 2D matrix, in small to large order
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Mathieu NOE
el 10 de Jun. de 2024
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)
Respuestas (1)
Prateekshya
el 8 de Jul. de 2024
Editada: Prateekshya
el 8 de Jul. de 2024
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.
0 comentarios
Ver también
Categorías
Más información sobre Operators and Elementary Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!