|
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.
|