I ran into a(nother) problem today and I have a hard time trying to figure out if Matlab has a predefined function for doing the following, or if and how I can create this on my own:

For n=1 I want a 2x1 matrix with the values:

0

1

For n=2 I want a 4x2 matrix with the values:

0 0

0 1

1 0

1 1

For n=3 I want a 8x3 matrix with the values:

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

... etc, depending on the value of n that I make. As you can see, the matrices that I want to create should contain all the possible outcomes of 0's and 1's for the given size of the matrix. The rows are, as you can see, of the size 2^n, and the columns are n-1.

I would really, and I mean really, love it if someone would be kind and try to help me out here...