repmat function

Fast replication of a matrix

Fast replication of a matrix

Fast generation of a matrix by replicating a matrix row- and column-wise in a block-like fashion

repmat(x, nrow = 1L, ncol = 1L)

Arguments

  • x: A matrix with dimensions r*c.
  • nrow: An integer giving the number of times the matrix is replicated row-wise
  • ncol: An integer giving the number of times the matrix is replicated column-wise

Returns

A matrix with dimensions (rnrow) x (cncol)

Examples

m <- matrix(1:6, ncol=3) repmat(m, 2) # Stack two copies of m on top of each other repmat(m, 2, 3) # Replicate m with two copies on top and three copies side-by-side

Author(s)

Claus Ekstrom claus@rprimer.dk

  • Maintainer: Claus Thorn Ekstrøm
  • License: GPL-2
  • Last published: 2023-08-20