Next: , Previous: spdiag, Up: Function Reference


22.6.0.27 spdiags

— function File: [b, c] = spdiags (a)
— function File: b = spdiags (a, c)
— function File: b = spdiags (v, c, a)
— function File: b = spdiags (v, c, m, n)

A generalization of the function spdiag. Called with a single input argument, the non-zero diagonals c of A are extracted. With two arguments the diagonals to extract are given by the vector c.

The other two forms of spdiags modify the input matrix by replacing the diagonals. They use the columns of v to replace the columns represented by the vector c. If the sparse matrix a is defined then the diagonals of this matrix are replaced. Otherwise a matrix of m by n is created with the diagonals given by v.

Negative values of c representive diagonals below the main diagonal, and positive values of c diagonals above the main diagonal.

For example

          spdiags (reshape (1:12, 4, 3), [-1 0 1], 5, 4)
          =>    5 10  0  0
                1  6 11  0
                0  2  7 12
                0  0  3  8
                0  0  0  4