spdiags
Extraction of diagonal/sub-or-super-diagonals of a matrix, or construction of a sparse matrix with given diagonal/sub-or-sper-diagonals.
(D,dind)=spdiags(A)
(D)=spdiags(A,d)
(S)=spdiags(A,d,B)
(S)=spdiags(A,d,m,n)
Inputs
A Any matrix
d A vector of integers specifying the diagonals of A .
B A matrix.
m An integer.
n An integer.
Outputs
D A matrix of various diagonals of A.
dind A vector of integers.
S A sparse matrix.


Description
spdiags(A) returns all the (m+n-1) diagonals of the pXq matrix A in the coulmns of D . In this context, a diagonal is one of the following: The vector dind is the integer vector [-(p-1):1:q-1] .

spdiags(A, d) , with each element of the integer vector d satisfying -(p-1)<=d[i]<=(q-1) , returns the matrix whose columns are the diagonals of A specified by the elements of d .

spdiags(A,d,m,n) returns an mXn sparse matrix whose diagonals specified by the vector d are the columns of A . The number of columns of A must be identical to the number of elements in d , and the elements of d must be in the range [-(m-1):1:(n-1)] . If m , the sub-diagonal (-N) of the resulting matrix is the part of the corrsponding column of A that begins from the row (N+1) , and all the super-diagonals of the resulting matrix are the approriate columns of A starting from the first row. Conversely, if m>=nn , the sub-diagonal (-N) of the resulting matrix is the part of the corresponding column of A that begins from the row (N+1) , and all the super-diagonals of the resulting matrix are the approriate columns of A starting from the first row.

spdiags(A,d,B) returns a sparse matrix constructed from mXn matrix B , but whose diagonals, specified by the vector d , are replaced by columns of A . The number of columns of A must be identical to the number of elements in d , and the elements of d must be in the range [-(m-1):1:(n-1)] .