Matrix Concatenation Functions
The following functions combine existing matrices to form a new matrix.
||Concatenate matrices along the specified dimension
||Horizontally concatenate matrices
||Vertically concatenate matrices
||Create a new matrix by replicating and tiling existing matrices
||Create a block diagonal matrix from existing matrices
Here are some examples of how you can use these functions.
Concatenating Matrices and Arrays. An alternative to using the
 operator for concatenation are the three functions
vertcat. With these functions, you can construct matrices (or multidimensional arrays) along a specified dimension. Either of the following commands accomplish the same task as the command
C = [A; B] used in the section on Concatenating Matrices:
Replicating a Matrix. Use the
repmat function to create a matrix composed of copies of an existing matrix. When you enter
MATLAB replicates input matrix
v times vertically and
h times horizontally. For example, to replicate existing matrix
A into a new matrix
Creating a Block Diagonal Matrix. The
blkdiag function combines matrices in a diagonal direction, creating what is called a block diagonal matrix. All other elements of the newly created matrix are set to zero:
|Concatenating Matrices||Generating a Numeric Sequence|
© 1994-2005 The MathWorks, Inc.