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
Amust 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
History
| Version | Description |
| 5.3.1 | Function repmat introduced. |
| Report an issue | ||
| << perms | Elementary matrices | squarewave >> |