B = repmat(A,r1,...,rN) specifies
a list of scalars, r1,..,rN, that describes how
copies of A are arranged in each dimension. When A has N dimensions,
the size of B is size(A).*[r1...rN].
For example, repmat([1 2; 3 4],2,3) returns a 4-by-6
matrix.
n — Number of times to repeat input array in row and column dimensions integer value
Number of times to repeat the input array in the row and column
dimensions, specified as an integer value. If n is 0 or
negative, the result is an empty array.
r1,...,rN — Repetition factors for each dimension (as separate arguments) integer values
Repetition factors for each dimension, specified as separate
arguments of integer values. If any repetition factor is 0 or
negative, the result is an empty array.
r — Vector of repetition factors for each dimension (as a row vector) integer values
Vector of repetition factors for each dimension, specified as
a row vector of integer values. If any value in r is 0 or
negative, the result is an empty array.
To build block arrays by forming the tensor product
of the input with an array of ones, use kron.
For example, to stack the row vector A = 1:3 four
times vertically, you can use B = kron(A,ones(4,1)).
To create block arrays and perform a binary operation
in a single pass, use bsxfun.
In some cases, bsxfun provides a simpler and
more memory efficient solution. For example, to add the vectors A
= 1:5 and B = (1:10)' to produce a 10-by-5
array, use bsxfun(@plus,A,B) instead of repmat(A,10,1)
+ repmat(B,1,5).
When A is a scalar of a certain
type, you can use other functions to get the same result as repmat.