I'm trying to generate all the unique permutations of an 8×3 matrix that is created when each row is one of the following:
[1,0,0] [0,1,0] or [0,0,1]
For example, one output would be:
ans = 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0
Another output would be:
ans = 0 1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0
And so on…
The following would not be accepted, because the third row [1,1,0] does not match one of the three input arrays.
ans = 0 0 1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 1 1 0 0 0 0 1
Ideally, this can be run in a for loop, so I don't have to store all of the permutations at once. However, I'd also like to know if there's an effective way to store this many matrices (perhaps a 3D matrix), so they can be referenced later.
Thank you,
Peter
Best Answer