help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: create matrix with all possible combinations


From: Thomas Shores
Subject: Re: create matrix with all possible combinations
Date: Mon, 02 Nov 2009 20:30:38 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Thunderbird/3.0b3

There are probably faster, simpler ways, but here's one:

n = 8;
x = (0:2^n-1)';
M = zeros(2^n,n);
for k = 1:n
  M(:,k) = mod(x,2);
  x = (x-M(:,k))/2;
end;



On 11/02/2009 06:43 PM, xeon wrote:
Hi,

I would like to create a matrix with 8 columns with all possible
combinations with the values 0 and 1 in Octave.

For example,
[0,0,0,0,0,0,0,0;1,0,0,0,0,0,0,0;0,1,0,0,0,0,0,0;...;1,1,1,1,1,1,1,1];

How can I do that?

thanks,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]