How to convert a 2D matrix to a 3D matrix without for cycles?

조회 수: 1 (최근 30일)
Mr M.
Mr M. 2018년 4월 5일
답변: Adam 2018년 4월 5일
Suppose we have a 2D matrix (M2) and we want to create 3D matrix (M3) from it with the following definition: M3(n,k,j) = M2((k-1)*J+j,n), where n=1:N, j=1:J, k=1:K

답변 (1개)

Adam
Adam 2018년 4월 5일
M3 = permute( reshape( M2', N, J, K ), [1 3 2] );
should do it I think, though there may be neater ways!

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by