# Matrix Manipulation

Suppose i have a column vector A = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}; What command can I use to extract every two succesive rows of vector A and turn them into columns to create matrix B = { 2 6 10 14 18, 4 8 12 16 20};?

0

I think the easiest way to do this is to use reshape function to
make A a 5x2 matrix and then transpose it.

A = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20};

/*
** 1. Use 'reshape' to make, B
**       2  4
**       6  8
**      10 12
**      14 16
**      18 20
**
** 2. Transpose the result of step 1.
*/
B = reshape(A, rows(A), 2)';

aptech

1,773

0

Thank you very much.

0

I think the easiest way to do this is to use reshape function to make A a 5x2 matrix and then transpose it.

A = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20};

/*
** 1. Use 'reshape' to make, B
**       2  4
**       6  8
**      10 12
**      14 16
**      18 20
**
** 2. Transpose the result of step 1.
*/
B = reshape(A, rows(A), 2)';

0

Thank you very much.

### Have a Specific Question?

Get a real answer from a real person

### Need Support?

Get help from our friendly experts.