user5603723
user5603723

Reputation: 193

Rearranging an array

I have a row array as shown below:

X1 Y1 Z1 X2 Y2 Z2 X3 Y3 Z3 X4 Y4 Z4 ..... Xn Yn Zn

This row array always starts with the value of X and with the value of Z. I want to rearrange them as a multidimensional array:

X1 X2 X3 X4 X5 .... Xn
Y1 Y2 Y3 Y4 Y5 .... Yn
Z1 Z2 Z3 Z4 Z5 .... Zn

The size of the original array varies in each case. Any help to how to approach this problem would be helpful.

Upvotes: 1

Views: 34

Answers (1)

rahnema1
rahnema1

Reputation: 15837

Use reshape function setting second dimension as []

reshaped_array = reshape(myarray,3,[]);

Upvotes: 3

Related Questions