How does the permute function in matlab work
matlab
Solution
`permute` does a permutation of the dimensions of an array, not of its elements, as one may expect from its name.
Thus, `permute(A,[2,1])` flips dimension 2 (the columns) of array `A` with dimension 1 (the rows) of array `A`, which is equivalent to a transpose (`A'`).
`permute(A,[3,2,1])` would produce a 1-by-2-by-2 array (because `size(A,3)==1`), where the array is "flipped up horizontally".
Problem
This is a somewhat silly question but I can't seem to figure out how permute works in matlab. Take the documentation example: ``` A = [1 2; 3 4]; permute(A,[2 1]) ans = 1 3 2 4 ``` What is going on? How does this tell matlab that the 3 and 2 need to be swapped?