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 Exchange에서 Structures에 대해 자세히 알아보기

태그

질문:

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