# [Matlab] Possible outcomes?

#### TheNewbie

##### New Member
Hey!
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...

#### Dason

I've never used Matlab but if nobody else has ideas I could write out some pseudocode to generate those matrices pretty easily.

#### TheNewbie

##### New Member
A friend of mine solved it.

for n={1,2...} you do:
a=[0 : (2^n)-1]
b=de2bi(a)