1 function PMs = permutation_matrices(integerN)
2 % Generate all permutation matrices of size ``integerN``.
6 % - ``integerN`` -- The dimension of the resulting matrices.
10 % - ``PMs`` -- A cell array of permutation matrices.
18 % Append to this as we generate them.
21 % Generate all permutations of [1,2,...,integerN].
22 permutations = perms([1:integerN]);
24 for idx = [ 1 : factorial(integerN) ]
25 sigma = permutations(idx,:);
26 % Create a permutation matrix from the permutation, sigma.
27 P = eye(integerN) (sigma,:);