From help-request at octave dot org Tue Jul 5 17:52:28 2005 Subject: Re: Finding all subsets From: =?ISO-8859-1?Q?S=F8ren_Hauberg?= To: "Hall, Benjamin" CC: Help-Octave List Date: Wed, 06 Jul 2005 00:50:58 +0200 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:soren at hauberg dot org] > 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 -------------------------------------------------------------