Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2025.0.0 - English


repmat

Replicate and tile an array

Syntax

B = repmat(A, siz)
B = repmat(A, m)
B = repmat(A, m, n,...)

Arguments

A
Array of any native type (boolean, numeric, text,..., cells, structures), of any number of dimensions of any sizes. Boolean or numerical sparse matrices are supported.

m, n, ...
Positive integers: number of times that A must be replicated along the respective dimensions #1, #2, etc..

siz
Vector of replication numbers: siz=[m,n,..].

B
Tiled array or ND-array, of sizes [m*size(A,1), n*size(A,2), ..] or [siz(1)*size(A,1), siz(2)*size(A,2), ..].

Description

repmat(A, m) replicates and tiles m × m copies of A.

repmat(A, m, n) or repmat(A, [m, n]) replicates and tiles m × n copies of A.

repmat(A, m, n, p, ..) is a generalization of repmat(A, m, n).

repmat(…) extends ones(m,n,..) .*. A to non-numerical inputs A.

repmat(…)'s definition can be extended using the overloading mechanism.

Examples

repmat([-1 3 7], 2, 4)

repmat(int8([1 -2 3; 0 -1  1]), 2, 4, 2)

b = cat(3, [%f %t %t], [%t %t %f])
repmat(b, [2 3])

t = "Scilab"; t(ones(2,4))
repmat(["Scilab" "Xcos"], 2, 3)

repmat([1/%s ; 2/(%s+1)], 1, 3)
--> repmat([-1 3 7], 2, 4)
 ans  =
  -1.   3.   7.  -1.   3.   7.  -1.   3.   7.  -1.   3.   7.
  -1.   3.   7.  -1.   3.   7.  -1.   3.   7.  -1.   3.   7.


--> repmat(int8([1 -2 3; 0 -1  1]), 2, 4, 2)
 ans  =
(:,:,1)
  1 -2  3  1 -2  3  1 -2  3  1 -2  3
  0 -1  1  0 -1  1  0 -1  1  0 -1  1
  1 -2  3  1 -2  3  1 -2  3  1 -2  3
  0 -1  1  0 -1  1  0 -1  1  0 -1  1
(:,:,2)
  1 -2  3  1 -2  3  1 -2  3  1 -2  3
  0 -1  1  0 -1  1  0 -1  1  0 -1  1
  1 -2  3  1 -2  3  1 -2  3  1 -2  3
  0 -1  1  0 -1  1  0 -1  1  0 -1  1


--> b = cat(3, [%f %t %t], [%t %t %f])
 b  =
(:,:,1)
  F T T
(:,:,2)
  T T F

--> repmat(b, [2 3])
 ans  =
(:,:,1)
  F T T F T T F T T
  F T T F T T F T T
 (:,:,2)
  T T F T T F T T F
  T T F T T F T T F


--> t = "Scilab"; t(ones(2,4))
 ans  =
  "Scilab"  "Scilab"  "Scilab"  "Scilab"
  "Scilab"  "Scilab"  "Scilab"  "Scilab"

--> repmat(["Scilab" "Xcos"], 2, 3)
 ans  =
  "Scilab"  "Xcos"  "Scilab"  "Xcos"  "Scilab"  "Xcos"
  "Scilab"  "Xcos"  "Scilab"  "Xcos"  "Scilab"  "Xcos"


--> repmat([1/%s ; 2/(%s+1)], 1, 3)
 ans  =
    1     1     1
    -     -     -
    s     s     s

    2     2     2
   ----  ----  ----
   1 +s  1 +s  1 +s

See also

  • kron — Kronecker tensorial product. Weighted array replication
  • ndgrid — build matrices or N-D arrays by replicating some template vectors
  • insertion — partial variable assignation or modification

History

VersionDescription
5.3.1 Function repmat introduced.
Report an issue
<< perms Matrix generation squarewave >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Oct 24 11:13:08 CEST 2024