Help with Reshaping Multidimensional Arrays

I have Multidimensional Arrays, but I need of a reshaped matrix, indexing columns of each "dimension".
The number of arrays and number of rows can change according to the user, like that:
A (1:x, 1:3, 1:y) if x= 3 and y = 2
A(:,:,1)= [1 2 3
4 5 6
7 8 9];
A(:,:,2)= [10 11 12
13 13 15
16 17 18];
Matlab answer
B = Reshape (A,x*y,3)
B= [1 3 11
4 6 13
7 9 17
2 10 12
5 13 15
8 16 18];
I need the answer:
B= [1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17 18];
Thank for your help

 採用された回答

Stephen23
Stephen23 2018 年 7 月 30 日

1 投票

reshape(permute(A,[1,3,2]),x*y,3)

1 件のコメント

Atan Cardoso
Atan Cardoso 2018 年 7 月 30 日
You're right Stephen, thank you!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

製品

リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by