Transposing 3 D matrix using permute - how does permute work?

조회 수: 14 (최근 30일)
Ali
Ali 2012년 1월 24일
댓글: Javed mohd 2018년 3월 7일
Ok. So I see how to transpose all the "2D slices" of a 3D matrix on other answers (permute(A, [2 1 3])).
But what does the order vector mean? The 2 means what? The second row, column? Anyone who can explain this, I appreciate it.
Thanks
  댓글 수: 2
Andrew Newell
Andrew Newell 2012년 1월 24일
Have you tried "doc permute" yet?
Javed mohd
Javed mohd 2018년 3월 7일
Hi, Order vector [1:first dim(row) 2:second dim(col) 3:third dim(Z)] so if you want to transpose rows and columns keeping the same Z, your vector would be [2 1 3]

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2012년 1월 24일
It is the dimension number. In [2 1 3] it means that the second dimension of the original should become the first dimension of the new array, and the first dimension of the original should become the second dimension of the new array, and the third dimension of the original should stay where it is.

추가 답변 (2개)

James Tursa
James Tursa 2012년 1월 25일
Another way to do 2D slice transposing of an nD Array:
mtimesx(1,A,'t')
You can find mtimesx on the FEX here:
href=""<http://www.mathworks.com/matlabcentral/fileexchange/25977-mtimesx-fast-matrix-multiply-with-multi-dimensional-support</a>>

Ali
Ali 2012년 1월 24일
Hello all,
Yeah.. I checked the docs before posted the message. I got it now. Thanks.
I think the docs could be improved a little bit, like an example.
A = [1 2; 3 4]
NewA = permute(A, [2,1,3])
=>
A(1,1) => NewA(1,1)
A(1,2) => NewA(2,1)
A(2,1) => NewA(1,2)
A(2,2) => NewA(2,2)
NewA = [1 3; 2 4]
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 1월 24일
The third dimension has length 1, and it is left where it is, so the third dimension is 1 afterwards. Trailing 1's from the third dimension onward are not explicitly shown in MATLAB. An array which is 2x2 is also 2x2x1x1x1x1x1 but it would not serve any useful purpose to explicitly display the 250-some-odd trailing subscripts that are all exactly "1".
Andrew Newell
Andrew Newell 2012년 1월 24일
Each doc page has an option for feedback at the bottom. If you answer "No" to "Was this topic helpful?", you'll get a web form to fill out.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by