All possible combinations (subgroups vary in size) of elements in a vector
Mostrar comentarios más antiguos
Hey,
I am trying to find a solution for the following problem:
I want to generate every possible combination of elements in a vector. The vector elements should always be split up in 2 groups. The groups can vary in size (number of elements), but all elements have to been included in the groups. The number of elements in a vector varies from 3 to 12.
Vector1 = [1 2 3 4]
Possible subgroups:
1 vs. 2,3,4
2 vs. 1,3,4
3 vs. 1,2,4
4 vs. 1,2,3
1,2, vs. 3,4
1,3 vs. 2,4
1,4 vs. 2,3
Vector2 =[1 2 3 4 5 6]
Size Subgroup1 = 1, Subgroup2 = 5
1 vs. 2,3,4,5,6
2 vs. 1,3,4,5,6
…
6 vs 1,2,3,4,5
Size Subgroup1 = 2, Subgroup2 = 4
1,2 vs. 3,4,5,6
1,3 vs. 2,4,5…
…
Size Subgroup1 = 3, Subgroup2 = 3
1,2,3 vs 4,5,6
1,2,4 vs 3,5,6
Size Subgroup1 = 4, Subgroup2 = 2
…
Size Subgroup1 = 5, Subgroup2 = 1
…
I have searched for a solution but I haven´t found one yet. Thanks!
Stephan
1 comentario
Andrea Ferrari Braga
el 26 de Sept. de 2012
Editada: Andrea Ferrari Braga
el 26 de Sept. de 2012
Hi, I'm searching for the solution of this problem too.
Do you find anything useful in this months ?
Thanks.
Andrea
Respuesta aceptada
Más respuestas (1)
Categorías
Más información sobre App Building 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!