Seperating columns into rows

조회 수: 1 (최근 30일)
Darrien Walters
Darrien Walters 2020년 10월 22일
댓글: Ameer Hamza 2020년 10월 22일
I have an array consisting of 1 column and multiple rows.
eg. B=(1:10);
i would like to make an array A which contains rows of every 2 numbers in B.
So array A would look like A = [1 3 5 7 9 ; 2 4 6 8 10];
A =
1 3 5 7 9
2 4 6 8 10
I am working with an extremely large data set that I am trying to segment. My first thought was using a for loop is this possible and if so how would I go about doing it?

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 10월 22일
편집: Ameer Hamza 2020년 10월 22일
Use reshape()
B = 1:10;
A = reshape(B, 2, [])
  댓글 수: 2
Darrien Walters
Darrien Walters 2020년 10월 22일
Thanks very much I was unaware of that function.
Ameer Hamza
Ameer Hamza 2020년 10월 22일
I am glad to be of help!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by