convert a 3D matrix to a 2D matrix
    7 次查看(过去 30 天)
  
       显示 更早的评论
    
Hello,
I'm trying to convert a A by B by C matrix (3D) into a A*C by B matrix (2D). But I need the column (with A*C elements) to be not stacked, but alternated. To explain,
I would like to convert a 2 by 2 by 3 matrix X:
val(:,:,1) =
     1     2
     1     2
val(:,:,2) =
     2     3
     2     3
val(:,:,3) =
     3     4
     3     4
into 2*3 by 2 matrix:
[1  2
 2  3
 3  4
 1  2
 2  3
 3  4]
I have tried:
X1=permute(X,[1 3 2]);
X2=reshape(X1,[6,2]);
but it generates:
X2 =
     1     2
     1     2
     2     3
     2     3
     3     4
     3     4
which is NOT what I want.
Is there a way to do this? Any advice appreciated!
0 个评论
采纳的回答
更多回答(1 个)
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


