Skip to content

Instantly share code, notes, and snippets.

@anirudhjayaraman
Created December 14, 2015 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anirudhjayaraman/37f5af3694eba8e975fc to your computer and use it in GitHub Desktop.
Save anirudhjayaraman/37f5af3694eba8e975fc to your computer and use it in GitHub Desktop.
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