Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!h21g2000yqa.googlegroups.com!not-for-mail
From: arun <aragorn168b@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Permutations in matlab
Date: Tue, 18 Aug 2009 02:24:06 -0700 (PDT)
Organization: http://groups.google.com
Lines: 27
Message-ID: <2077bec6-d1df-4261-b655-49187dfe5785@h21g2000yqa.googlegroups.com>
References: <h6dfju$juk$1@fred.mathworks.com> <h6dksn$q0v$1@fred.mathworks.com> 
	<h6dq5d$3r0$1@fred.mathworks.com>
NNTP-Posting-Host: 134.2.162.116
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1250587446 22562 127.0.0.1 (18 Aug 2009 09:24:06 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 18 Aug 2009 09:24:06 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: h21g2000yqa.googlegroups.com; posting-host=134.2.162.116; 
	posting-account=fyqXpgoAAABqt-0BifyaNxmZhzggFACu
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; 
	rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:564134


On Aug 18, 10:53 am, "Midhun " <midhunj...@gmail.com> wrote:
> > I think you want perms().
>
> Thanks for your post. Infact, I was looking for a command in which I could specify the size of the subset ( not possible in ' perms(set) '  :  all permutations would contain all the elements in the set. )
>
> It is possible to do it in a roundabout way :  take ' combntns(set,n)  '   to get various combinations/subsets of size 'n' . For each of these rows , take perms() to get all possible permutations.  Is it possible to do this using a single built-in command ?

yes there is no direct function for permutations, as there is 1 for
combinations. Probably because its not possible to store the
permutations for n>= 11 (documentation says it takes over 3GB).

however, for small amount of numbers you could do,

a = 1:4;

acn = nchoosek(a,3);
result = arrayfun(@(x) perm(acn(x,:)), 1:length(acn), 'uni', false);
result = cat(1,result{:});

to get the permutations.

best, arun.