All possible sets from vector

2 visualizaciones (últimos 30 días)
Paul
Paul el 18 de Oct. de 2015
Comentada: Paul el 19 de Oct. de 2015
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 comentarios
Steven Lord
Steven Lord el 18 de Oct. de 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].
Paul
Paul el 19 de Oct. de 2015
Editada: Paul el 19 de Oct. de 2015
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.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 19 de Oct. de 2015
Editada: Walter Roberson el 19 de Oct. de 2015
  1 comentario
Paul
Paul el 19 de Oct. de 2015
Exactly what I was looking for Thank you.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by