[Solved] MATLAB: Compute all possible column permutations of a matrix


If I understand correctly, you can generate all permutations of column indices with perms, and use the result to index into the matrix:

M = magic(3);              % // example matrix
pp = perms(1:size(M,2));   % // each row is a permutation
for p = pp.'               %'// "for" loops over columns, so transpose pp
    permuted_M = M(:,p);   % // matrix with permuted columns
end

solved MATLAB: Compute all possible column permutations of a matrix