Thread Subject: Listing sequential binary numbers in vector form

Subject: Listing sequential binary numbers in vector form

From: Camron Call

Date: 11 Mar, 2009 00:52:01

Message: 1 of 3

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.

Subject: Listing sequential binary numbers in vector form

From: Darren Rowland

Date: 11 Mar, 2009 01:12:01

Message: 2 of 3

I think your question has been answered very recently in this thread
http://www.mathworks.com/matlabcentral/newsreader/view_thread/246265

Darren

Subject: Listing sequential binary numbers in vector form

From: Camron Call

Date: 11 Mar, 2009 20:05:19

Message: 3 of 3

"Darren Rowland" <darrenjremovethisrowland@hotmail.com> wrote in message <gp7351$2pl$1@fred.mathworks.com>...
> I think your question has been answered very recently in this thread
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/246265
>
> Darren


Absolutely beautiful!!! Thanks for your link. Subtracting -'0' is a handy trick.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
dec2bin crc 10 Mar, 2009 20:55:04
rssFeed for this Thread

Contact us at files@mathworks.com