Clear Filters
Clear Filters

List all possible outcomes of 16 matches

2 views (last 30 days)
I am trying to make a code that will list all of the possible outcomes of 16 matches (only wins or losses, no draws), essentially the same as flipping a coin 16 times. I've tried using functions like combnk and nchoosek, but they cannot build a 16 column matrix with only two outcomes.
Ideally, the outcome would be a 16 X 4096 matrix (65,536 combinations) which would look like this
H H H H H H H H H H H H H H H H
H H H H H H H H H H H H H H H A
H H H H H H H H H H H H H H A H
And so on. Or, if the argument needed numbers, like this
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1
...
Thank you for your help!

Accepted Answer

Bruno Luong
Bruno Luong on 19 Sep 2018
dec2bin(0:2^16-1)-'0'

More Answers (0)

Categories

Find more on Matrices and Arrays 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!