How to convert a 2D array 1632x11 to a 3D array 32x11x51 ?

6 ビュー (過去 30 日間)
Jam jammy
Jam jammy 2015 年 7 月 25 日
コメント済み: Jam jammy 2015 年 7 月 25 日
I have '1632x11' array and I would like to convert it to '32x11x51' array such that the values (32x11) after every 32 rows move to next page (thereby creating 51 pages) in an identical order as in 2D matrix i.e the values in row 33 of the 2D array become the values of row1 of page 2 in 3D array and so on.
I tried reshape, permute with reshape functions, these functions created the arrays but the results are not that I would like to have.
It would be really appreciated if someone can help me with this issue.

採用された回答

Jan
Jan 2015 年 7 月 25 日
It will work with reshape and permute. I guess you want this:
X = rand(1632, 11);
Y = permute(reshape(X, 32, 51, 11), [1, 3, 2]);
If you want something else, simply play with the order. For some results an initial permutation (e.g. a transpose) is required.
  1 件のコメント
Jam jammy
Jam jammy 2015 年 7 月 25 日
Thank you for a quick revert, this is exactly what I wanted. While using the permute, my order was different hence the undesired result.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by