[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: create matrix with all possible combinations
From: |
Jaroslav Hajek |
Subject: |
Re: create matrix with all possible combinations |
Date: |
Tue, 3 Nov 2009 13:53:44 +0100 |
On Tue, Nov 3, 2009 at 1:43 AM, xeon <address@hidden> 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,
>
With 3.3.50+, it's easy:
reshape (bitunpack (uint8(0:255)), 8, []).'
--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz