I want to create a matrix containing all possible combination. Example of this is shown below. The size of the matrix depends on the number of variable n and the total of combination should follow the . The example below is valid for and, hence, the total number of rows is 8. The value of each element is 0 and 1.
How to create this matrix automatically depending on the number of variable n?
You'll have to extract the indices from the columns but that should be "not hard". There's more than likely many prettier solutions, for example have a look on the file exchange for nextperm (by Jos) and next-combination-permutation (by Matt-Fig).