2013-07-24 231 views
-5

A是多維向量3x3x3。我想將其更改爲9x3矢量。我如何在matlab中做到這一點?將多維向量更改爲二維向量matlab

+4

可能重複](http://stackoverflow.com/questions/15102216/reshaping-a-matrix-in-matlab),[如何在MATLAB中調整矩陣?](http://stackoverflow.com/questions/793574/how -DO-I-調整大小-a-matrix-in-matlab),[重塑三維矩陣到二維矩陣](http://stackoverflow.com/questions/2256925/reshape-3d-matrix-to-2d-matrix)等等... –

+1

我可以理解closevotes,但爲什麼downvoting?問題很明顯,如果不知道正確的關鍵詞,找到解決方案並不是微不足道的。 –

回答

2

您可以使用reshape函數來實現。

B = reshape(A,9,3);

1
vector2D = cat(2,vector3D(:,:,1),vector3D(:,:,2),vector3D(:,:,3)) 

vector2D = cat(1,vector3D(:,:,1),vector3D(:,:,2),vector3D(:,:,3)) 

先前將安排沿着行的2D矢量,而後面將安排他們allong colums

[重塑在Matlab矩陣