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

4 vues (au cours des 30 derniers jours)
Isti
Isti le 7 Mai 2012
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 :)

Réponse acceptée

Jan
Jan le 7 Mai 2012
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.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by