我有一個大小爲KxNxZ的3D矩陣。 我想將第三維中的子矩陣連接成一個大小爲K * ZxN,s.t的單個二維矩陣。它們將按行連接起來。 達到這個結果的最好方法是什麼?MATLAB - 第三矩陣維度的連接
謝謝!
實施例:
%generates input
M = cat(3,[(1:3)',(4:6)'],[(7:9)',(10:12)'],[(13:15)',(16:18)']);
DesiredOutput = [[(1:3)';(7:9)';(13:15)'],[(4:6)';(10:12)';(16:18)']];
輸入矩陣
M(:,:,1) =
1 4
2 5
3 6
M(:,:,2) =
7 10
8 11
9 12
M(:,:,3) =
13 16
14 17
15 18
希望的輸出矩陣:
DesiredOutput =
1 4
2 5
3 6
7 10
8 11
9 12
13 16
14 17
15 18
我建議你看看'reshape'和'permute'函數,並與他們玩一下。你應該能夠得到你正在尋找的結果:) – Eskapp