spdiags
[B, d] = spdiags (A) extract the nonzero diagonals of A B = spdiags (A, d) extract the diagonals listed in d S = spdiags (B, d, m, n) build an m-by-n sparse matrix from diagonals S = spdiags (B, d, A) replace the diagonals d of A by the columns of B Storage convention: for an m-by-n matrix with m >= n, entry B(j,k) is A(j-d(k), j) (indexed by column); for m < n it is A(i, i+d(k)) (indexed by row).