Main Content
repmat
Repeat copies of array
Description
Examples
Input Arguments
Tips
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 vectorA = 1:3
four times vertically, you can useB = 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 vectorsA = 1:5
andB = (1:10)'
to produce a 10-by-5 array, usebsxfun(@plus,A,B)
instead ofrepmat(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 asrepmat
.repmat Syntax Equivalent Alternative repmat(NaN,m,n)
NaN(m,n)
repmat(single(inf),m,n)
inf(m,n,'single')
repmat(int8(0),m,n)
zeros(m,n,'int8')
repmat(uint32(1),m,n)
ones(m,n,'uint32')
repmat(eps,m,n)
eps(ones(m,n))