![](/img/trans.png)
[英]Get Matrix 2D from Matrix 3D with a given choice of the third dimension corresponding to the first dimension
[英]Matlab - Transpose a 3D matrix only in the third dimension
我有一個3 x 3 x 2矩陣,例如:
M(:,:,1) =
1 2 3
4 5 6
7 8 9
M(:,:,2) =
10 11 12
13 14 15
16 17 18
我想轉置每個M(:,:,i)
,我的意思是我希望:
M(:,:,1) =
1 4 7
2 5 8
3 6 9
M(:,:,2) =
10 13 16
11 14 17
12 15 18
如何在沒有循環的情況下做到這一點? 非常感謝你 !
這就是permute
作用:
result = permute(M, [2 1 3]); %// swap dimensions 1 and 2
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.