Seperating columns into rows

2 views (last 30 days)
Darrien Walters
Darrien Walters on 22 Oct 2020
Commented: Ameer Hamza on 22 Oct 2020
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?

Accepted Answer

Ameer Hamza
Ameer Hamza on 22 Oct 2020
Edited: Ameer Hamza on 22 Oct 2020
Use reshape()
B = 1:10;
A = reshape(B, 2, [])
  2 Comments
Darrien Walters
Darrien Walters on 22 Oct 2020
Thanks very much I was unaware of that function.
Ameer Hamza
Ameer Hamza on 22 Oct 2020
I am glad to be of help!!!

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!