s = spdiagmat(A,numRep)

Returns a sparse matrix of size numRep*size(A) and fills elements along the diagonal with the matrix A as shown below.

Download

Example

A = sparse([1 1 1 1; 2 2 2 2]);

B = spdiagmat(A,3);

full(B)

## === expected output ===

## ans =
##
## 1 1 1 1 0 0 0 0 0 0 0 0
## 2 2 2 2 0 0 0 0 0 0 0 0
## 0 0 0 0 1 1 1 1 0 0 0 0
## 0 0 0 0 2 2 2 2 0 0 0 0
## 0 0 0 0 0 0 0 0 1 1 1 1
## 0 0 0 0 0 0 0 0 2 2 2 2


imprint