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 Camron Call 10 Mar, 2009 20:55:04
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com