Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Create a list of permuation matrices in Octave / Matlab
% function to generate permutation matrices given the size of the desired permutation matrices
function x = permMatrices(n)
x = zeros(n,n,factorial(n));
permutations = perms(1:n);
for i = 1:size(x,3)
x(:,:,i) = eye(n)(permutations(i,:),:);
end
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment