Skip to content

repmat

Tile an array by replicating its contents.

B = repmat(A, n)
B = repmat(A, m, n)
B = repmat(A, m, n, p, ...)
B = repmat(A, [m n ...])

Builds a tiled array by replicating A. repmat(A, m, n) produces an m × n block grid of copies of A; the result has size [size(A,1)*m, size(A,2)*n]. The single-integer form repmat(A, n) is equivalent to repmat(A, n, n). The vector form takes the tile counts per dimension.

repmat([1 2; 3 4], 2) % 4×4: [1 2 1 2; 3 4 3 4; 1 2 1 2; 3 4 3 4]
repmat([1 2 3], 4, 1) % 4×3 of identical rows
repmat(eye(2), [2 2 3]) % 4×4×3 stack
  • repelem — Replicate array elements (per-element repetition).
  • reshape — Reshape an array without changing its data.
  • cat — Concatenate arrays along a specified dimension.