All possible sets from vector
11 views (last 30 days)
Show older comments
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 Comments
Steven Lord
on 18 Oct 2015
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].
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!