Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Listing sequential binary numbers in vector form
Date: Wed, 11 Mar 2009 00:52:01 +0000 (UTC)
Organization: University of Utah
Lines: 26
Message-ID: <gp71vh$qqd$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1236732721 27469 172.30.248.38 (11 Mar 2009 00:52:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 11 Mar 2009 00:52:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 811741
Xref: news.mathworks.com comp.soft-sys.matlab:523913


I am trying to create a matrix listing all the binary numbers from 0 to 2^n-1 where n is an integer (no need for n>12).  I understand that if n = 3 then:

dec2bin(0:2^n-1)

will gives the following in a string format.

000
001
010
011
100
101
110
111

I would like to figure out how to get the same thing in a matrix in number format such as:

[0 0 0;
0 0 1;
0 1 0;
...
1 1 1]

I don't need to use dec2bin if there is an easier way, but that's where I started.

any ideas would be appreciated.