| MATLAB Function Reference | ![]() |
Syntax
B = repmat(A,m,n) B = repmat(A,[m n]) B = repmat(A,[m n p...]) repmat(A,m,n)
Description
矩陣 B = repmat(A,m,n)
B包含 m x n 個的複製 A。repmat(A,n) 產生包含 n x n 個複製 A 的矩陣。
B = repmat(A,[m n])
同於 repmat(A,m,n)。
B = repmat(A,[m n p...])
產生一個包含複製 A 的多維(m x n x p x ...)陣列。A 可以是多維的。
repmat(A,m,n)
當 A 為純量時,會產生一個元素值為 A、維度為 m x n 的矩陣。當 m 或 n 較大時,其運算速度較 a*ones(m,n) 快。
Examples
在下面的例子中,repmat 複製 12 份二階單位矩陣產生棋盤圖形。
B = repmat(eye(2),3,4)
B =
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
陳述式 N = repmat(NaN,[2 3]) 產生一個元素為 NaN、維度為 2 x 3 的矩陣。
| rem | reset | ![]() |