> How to make a matrix from other matrices in Matlab?

How to make a matrix from other matrices in Matlab?

Posted at: 2014-12-18 
Say for example, A, B and C are all 4x4 matrices and I want to make a matrix that has rows 1 and 3 from A, row 2 from B and row 4 from C.

That one's pretty easy actually. You can extract whole rows using the colon operator, and you can concatenate matrices using square brackets (and semi-colons to indicate vertical concatenation):

D = [A(1, :) ; B(2, :) ; A(3, :) ; C(4, :)];

A(n, :) extracts the nth row from A. A(:, m) extracts the mth column from A.

Say for example, A, B and C are all 4x4 matrices and I want to make a matrix that has rows 1 and 3 from A, row 2 from B and row 4 from C.