All possible sets from vector

조회 수: 11 (최근 30일)
Paul
Paul 2015년 10월 18일
댓글: Paul 2015년 10월 19일
I have a vector x = 1:n and I need to compute all sets from it. So for example x = [1 2 3 4] should produce:
[1] [2] [3] [4]
[1 2] [3 4]
[1 2] [3] [4]
[1 3] [2 4]
[1 3] [2] [4]
[1 4] [2 3]
[1 4] [2] [3]
[2 3] [1] [4]
[2 4] [1] [3]
[3 4] [1] [2]
[1 2 3] [4]
[1 2 4] [3]
[1 3 4] [2]
[2 3 4] [1]
[1 2 3 4]
  댓글 수: 2
Steven Lord
Steven Lord 2015년 10월 18일
How large is n going to be in your real (not example) case? That will determine if such a scenario is feasible.
Does order matter? You have both [3 4][1 2] and [1 2][3 4] in your list, but you don't have for example [4][2][3][1].
Paul
Paul 2015년 10월 19일
편집: Paul 2015년 10월 19일
Sorry my bad ... order doesn't matter so [3 4] [1 2] and [1 2] [3 4] are the same set. In my cases n<= 15.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2015년 10월 19일
편집: Walter Roberson 2015년 10월 19일
  댓글 수: 1
Paul
Paul 2015년 10월 19일
Exactly what I was looking for Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by