cancatenate matrices a and b in matlab

To concatenate matrices a and b in MATLAB, you can use the vertcat or horzcat functions depending on whether you want to concatenate them vertically or horizontally.

To concatenate them vertically, use vertcat:

newMat = vertcat(a, b);
24 chars
2 lines

To concatenate them horizontally, use horzcat:

newMat = horzcat(a, b);
24 chars
2 lines

Note that the number of rows in matrices a and b must be the same for horizontal concatenation, and the number of columns in matrices a and b must be the same for vertical concatenation.

related categories

gistlibby LogSnag