Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Building a Logical Array For Factorial Application
Date: Sat, 6 Oct 2012 07:16:06 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 47
Message-ID: <k4olrm$bjd$1@newscl01ah.mathworks.com>
References: <k4n1mv$7du$1@newscl01ah.mathworks.com> <k4njkp$iif$1@newscl01ah.mathworks.com> <k4noga$5b7$1@newscl01ah.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1349507766 11885 172.30.248.35 (6 Oct 2012 07:16:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 6 Oct 2012 07:16:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:779999

"Maxx Chatsko" wrote in message <k4noga$5b7$1@newscl01ah.mathworks.com>...

> 
> The factorial simply represents all the possible combinations of my hardware. If I have seven (7) channels that can be active or not active at one time, then the total amount of unique combinations is 7!. 

The number of all combinations of 7 channels on/off is 2^7, not 7!. James gave you the code to do that.

>These include having one channel on six off, two channels on five off, three channels on four off. 

Don't understand this part.

> 
> Although now that I wrote that it seems it will be less than 7!. Perhaps only 3! or 4! since there will be repeats if I continue the thought of the last paragraph. 

You could provide perhaps a simple example with e.g., 3 channels. What is the logical array you want to get?

James's code give this

>> dec2bin((0:(2^3-1))')-'0'

ans =

     0     0     0
     0     0     1
     0     1     0
     0     1     1
     1     0     0
     1     0     1
     1     1     0
     1     1     1

Each row tells which channel is on (1) or off (0). There are 2^3=8 combination of those.

If you want to order the channels, then the number of combinations is 7!. This this is completely different problem, and one cannot store the ordering with a binary but with an array of permutations, i.e., (1:numberchannels), permuted in each row:

>> perms(1:3)

ans =

     3     2     1
     3     1     2
     2     3     1
     2     1     3
     1     2     3
     1     3     2

% Bruno