Filter löschen
Filter löschen

Permutation of variables with different states - get all combinations

1 Ansicht (letzte 30 Tage)
Marv
Marv am 24 Aug. 2018
Beantwortet: Stephen23 am 24 Aug. 2018
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 ? :)

Antworten (1)

Stephen23
Stephen23 am 24 Aug. 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

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by