Code covered by the BSD License

### Highlights from ALL PERMUTATIONS OF SEQUENCE

2.0
2.0 | 1 rating Rate this file 4 Downloads (last 30 days) File Size: 1.34 KB File ID: #37558

# ALL PERMUTATIONS OF SEQUENCE

### Sandeep Solanki (view profile)

Generates All Permutations of a sequence

File Information
Description

% Syntax
% "b = allperm(n)" Generates all permutations of Sequence [1:n].
%
% Input :
% n : Greatest Number in Sequence
%
% Output :
% b : output as cell array
%
% Example 1.
% b = allperm(2)
% b =
% {[1 2],[2 1]}
%
% Example 2.
% b = allperm(3)
% b =
% {[1 2 3],[1 3 2],[2 1 3],[2 3 1],[3 1 2],[3 2 1]}
%
% order may be different
%
% Programmed By :
% - Sandeep Solanki
% - rtm_sandeep@rediffmail.com

MATLAB release MATLAB 7.9 (R2009b)
Tags for This File   Please login to tag files.
Comments and Ratings (3)
19 Jul 2012 Jan Simon

### Jan Simon (view profile)

19 Jul 2012 Jan Simon

### Jan Simon (view profile)

This is an extremly inefficient implementation. It creates random permutations by the (slow) RANDPERM in an infinite loop (for i=1:inf). Then inn a FOR loop it is checked, if the perumtation is stored already. For n=10 this takes ages.
Beside Matlab's RANDPERM you find several more efficient solutions in the FEX.

Comment only
19 Jul 2012 Bruno Luong

See MATLAB perms

Comment only