MATLAB: How to split a matrix into 2 matrixes then join it again

join matrixsplit matrix

I have a mtrix like this: A =[2,6,3,1,7;9,4,2,6,3;7,1,4,5,3;7,2,5,6,3;4,2,5,3,5]
A =
2 6 3 1 7
9 4 2 6 3
7 1 4 5 3
7 2 5 6 3
4 2 5 3 5
then i want to split it become 2 matrix A1 and A2. So it will be like this:
A1 =
2 6 3 1 7
9 4 2 6 3
7 1 4 5 3
A2 =
7 2 5 6 3
4 2 5 3 5
After i finish with my process with that 2 matrix above, I want join them again into a matrix.
What to do? Thanks before 🙂

Best Answer

A =[2,6,3,1,7;9,4,2,6,3;7,1,4,5,3;7,2,5,6,3;4,2,5,3,5];
A1 = A(1:3, :);
A2 = A(4:5, :);
B = cat(1, A1, A2); % Or [A1; A2]
These basic array operations are explained exhaustively in the Getting started chapters of the documentation.