Reshape multidimensional matrix by page

Suppose you have a multidimensional array A: 64x64x16. How do you reshape it efficiently so A(:,:,1) to A(:,:,16) are 64x64 blocks that form a new 256x256 matrix?
The desired result (256 x 256) is:
[A(:,:,1) A(:,:,2) A(:,:,3) A(:,:,4); A(:,:,5) A(:,:,6) A(:,:,7) A(:,:,8); A(:,:,9) A(:,:,10) A(:,:,11) A(:,:,12); A(:,:,13) A(:,:,14) A(:,:,15) A(:,:,16)]

2 件のコメント

Nek Valous
Nek Valous 2011 年 8 月 18 日
Thank you.
Jan
Jan 2011 年 8 月 18 日
You can edit your original question to insert the missing ")" in the first line.

サインインしてコメントする。

 採用された回答

Jan
Jan 2011 年 8 月 18 日

2 投票

A = rand(64, 64, 16);
B = reshape(permute(reshape(A, 64, 64*4, 4), [1,3,2]), [256, 256]);
C = [A(:,:,1) A(:,:,2) A(:,:,3) A(:,:,4); ...
A(:,:,5) A(:,:,6) A(:,:,7) A(:,:,8); ...
A(:,:,9) A(:,:,10) A(:,:,11) A(:,:,12); ...
A(:,:,13) A(:,:,14) A(:,:,15) A(:,:,16)];
isequal(B, C)

2 件のコメント

Nek Valous
Nek Valous 2011 年 8 月 18 日
Thank you! Very elegant!
Jan
Jan 2011 年 8 月 18 日
You are welcome.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2011 年 8 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by