Permutation of variables with different states - get all combinations
1 view (last 30 days)
Show older comments
Hello guys, I have four IDs:
- A
- B
- C
- D
For each ID different states are possible (note, that A/B have different states than C/D):
- A [1; 2; 3]
- B [1; 2; 3]
- C [1; 3; 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 ? :)
0 Comments
Answers (1)
Stephen23
on 24 Aug 2018
>> 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
0 Comments
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!