|
SOLUTIONS
|
Mathematica
>
Mathematics and Algorithms
>
Matrices and Linear Algebra
>
Constructing Matrices
>
DiagonalMatrix
BUILT-IN MATHEMATICA SYMBOL
DiagonalMatrix
DiagonalMatrix[list]
gives a matrix with the elements of list on the leading diagonal, and
elsewhere.
DiagonalMatrix[list, k]
gives a matrix with the elements of list on the k
diagonal.
DiagonalMatrix[list, k, n]
pads with
s to create an n×n matrix.
DetailsDetails
- For positive k, DiagonalMatrix[list, k] puts the elements k positions above the main diagonal. DiagonalMatrix[list, -k] puts the elements k positions below.
- DiagonalMatrix[list, k] fills the k
diagonal of a square matrix with the elements from list. Different values of k lead to different matrix dimensions. - DiagonalMatrix[list, k, n] always creates an n×n matrix, even if this requires dropping elements of list. »
- DiagonalMatrix[list, k, {m, n}] creates an m×n matrix.
- DiagonalMatrix[SparseArray[...], ...] gives a SparseArray object.
New in 1 | Last modified in 7
Mathematica 9 is now available!
New to Mathematica?
Find your learning path »
Have a question?
Ask support »
