MATLAB: How to change a 1×10 matrix into two 1×5 matrices.

coordinatesmatrixmatrix manipulation

I'm trying to convert a 1×10 matrix which currently looks like this [x; y; x; y; x; y; x; y; x; y;] into two separate matrices of [x; x; x; x; x;] [y; y; y; y; y;]. How can I do this? Thanks

Best Answer

You typed [x; y; x; y; x; y; x; y; x; y;], which will result in a 10x1 matrix instead of 1x10. In any case, you can use reshape(), for example
>> x = [1 2 1 2 1 2 1 2 1 2]
x =
1 2 1 2 1 2 1 2 1 2
>> y = reshape(x, 2, [])
y =
1 1 1 1 1
2 2 2 2 2