All possible combinations (subgroups vary in size) of elements in a vector
이전 댓글 표시
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
Andrea Ferrari Braga
2012년 9월 26일
편집: Andrea Ferrari Braga
2012년 9월 26일
Hi, I'm searching for the solution of this problem too.
Do you find anything useful in this months ?
Thanks.
Andrea
채택된 답변
추가 답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 App Building에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!