repmat

Replicates an input to create a block matrix with the number of specified replications in each dimension.

Syntax

repmat (A, m)

repmat (A, m, n, ...)

repmat (A, [m, n, ...])

Inputs

A
Value to copy.
Type: double | integer | char | string | logical | struct | cell
Dimension: matrix
n,m
Dimensions of the desired matrix.
Type: double | integer | char | string | logical | struct | cell
Dimension: matrix

Outputs

R
The block matrix.

Examples

One input dimension:
R = repmat([1,2;3,4],3)
R = [Matrix] 6 x 6
1  2  1  2  1  2
3  4  3  4  3  4
1  2  1  2  1  2
3  4  3  4  3  4
1  2  1  2  1  2
3  4  3  4  3  4
Two input dimensions:
R = repmat([1,2,3;4,5,6],4,2)
R = [Matrix] 8 x 6
1  2  3  1  2  3
4  5  6  4  5  6
1  2  3  1  2  3
4  5  6  4  5  6
1  2  3  1  2  3
4  5  6  4  5  6
1  2  3  1  2  3
4  5  6  4  5  6

Comments

When only one replication dimension is specified, it is applied in the first two dimensions to form a square pattern of blocks, similar to ones(n).