Azzera filtri
Azzera filtri

Permutation of variables with different states - get all combinations

1 visualizzazione (ultimi 30 giorni)
Hello guys, I have four IDs:
  1. A
  2. B
  3. C
  4. D
For each ID different states are possible (note, that A/B have different states than C/D):
  1. A [1; 2; 3]
  2. B [1; 2; 3]
  3. C [1; 3; 4]
  4. D [1; 3; 4]
I would like to permutate these states and get all combinations:
A B C D
1 3 4 3
....
How can I do that in matlab ? :)

Risposte (1)

Stephen23
Stephen23 il 24 Ago 2018
Download Jos's excellent allcomb, and use it like this:
>> allcomb([1,2,3],[1,2,3],[1,3,4],[1,3,4])
ans =
1 1 1 1
1 1 1 3
1 1 1 4
1 1 3 1
1 1 3 3
1 1 3 4
1 1 4 1
1 1 4 3
1 1 4 4
1 2 1 1
1 2 1 3
1 2 1 4
1 2 3 1
1 2 3 3
1 2 3 4
1 2 4 1
1 2 4 3
1 2 4 4
1 3 1 1
1 3 1 3
1 3 1 4
1 3 3 1
1 3 3 3
1 3 3 4
1 3 4 1
1 3 4 3
1 3 4 4
2 1 1 1
2 1 1 3
2 1 1 4
2 1 3 1
2 1 3 3
2 1 3 4
2 1 4 1
2 1 4 3
2 1 4 4
2 2 1 1
2 2 1 3
2 2 1 4
2 2 3 1
2 2 3 3
2 2 3 4
2 2 4 1
2 2 4 3
2 2 4 4
2 3 1 1
2 3 1 3
2 3 1 4
2 3 3 1
2 3 3 3
2 3 3 4
2 3 4 1
2 3 4 3
2 3 4 4
3 1 1 1
3 1 1 3
3 1 1 4
3 1 3 1
3 1 3 3
3 1 3 4
3 1 4 1
3 1 4 3
3 1 4 4
3 2 1 1
3 2 1 3
3 2 1 4
3 2 3 1
3 2 3 3
3 2 3 4
3 2 4 1
3 2 4 3
3 2 4 4
3 3 1 1
3 3 1 3
3 3 1 4
3 3 3 1
3 3 3 3
3 3 3 4
3 3 4 1
3 3 4 3
3 3 4 4

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by