How to reshape an array in a specific manner

Hi all,
I was trying to reshape an array in a specific manner, however I couldn't accomplish that. Here is the example:
I have the following array:
a = [1 ; 2 ; 3 ; 1 ; 2 ; 3 ; 1 ; 2 ; 3 ; 1 ; 2 ; 3] ;
Which I would like to reshape to:
A = [1 2 3 ; 1 2 3 ; 1 2 3 ; 1 2 3] ;
How can I do this?
I have tried A=reshape(a, 4, 3) however it is returning A=[1 2 3 ; 2 3 1 ; ... etc
Thanks for your help in advance,
KMT

 採用された回答

dpb
dpb 2020 年 2 月 17 日

0 投票

>> reshape(a,3,[]).'
ans =
1 2 3
1 2 3
1 2 3
1 2 3
>>

2 件のコメント

KostasK
KostasK 2020 年 2 月 17 日
thanks for that!
dpb
dpb 2020 年 2 月 17 日
Remember column-major storage order...

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

その他の回答 (1 件)

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

質問済み:

2020 年 2 月 17 日

コメント済み:

dpb
2020 年 2 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by