Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: Français - Português - 日本語 - Русский
Scilab Help >> Elementary Functions > Matrix generation > repmat

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.

Comments

Author : Sylvestre LEDRU posted the 19/06/2011 10:51
Function available since Scilab 5.3.1
Reply to this comment
Please login to comment this page


See comments in other languages: Français: 1 comment(s)

Add a comment:
Please login to comment this page.

Report an issue
<< perms Matrix generation squarewave >>

Scilab Enterprises
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Jul 20 11:10:42 CEST 2021