MATLAB: All possible sequences of 1 and 0 for length N

permutationssequences

I would like to create an matrix of all possible sequences of the numbers 1 and 0 of length N. For example if N=2 there are 4 possible sequences, they are [1, 1; 1, 0; 0, 1; 0 ,0]. I would like to do this procedure for up to N=20

Best Answer

dec2bin(0:2^N-1) - '0'