help-octave
[Top][All Lists]
Advanced

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

Re: Finding all subsets


From: Søren Hauberg
Subject: Re: Finding all subsets
Date: Wed, 06 Jul 2005 00:50:58 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050404)

Hall, Benjamin wrote:
Does nchoosek help?

v = 1:3;
for kk = 0:length(v)
   nchoosek( v, kk )
end
That's just beautiful. This is why you ask questions at forums :-)

/Søren



-----Original Message-----
From: Søren Hauberg [mailto:address@hidden
Sent: Tuesday, July 05, 2005 10:10 AM
To: Mike Miller
Cc: Help-Octave List
Subject: Re: Finding all subsets


Mike Miller wrote:

On Tue, 5 Jul 2005, Soren Hauberg wrote:


I can't seem to wrap my mind around a very simple problem.
I need to find all possible subsets of a set.
Example:
All possible subsets of
[1, 2, 3]
is
{ [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3] }


Is [] (null set) also a subset?

I guess it is, I simply forgot to list it.


An n-vector has 2^n subsets, if the null set is included.

I'm not sure what the best way is to extract the subsets and I don't know how you want them organized in matrices or whatever.

The best way would be a cell array of vectors (octave represents sets as vectors).



Mike

Thanks,
Søren



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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