Mathematica > Mathematics and Algorithms > Matrices and Linear Algebra > Constructing Matrices >

DiagonalMatrix

Updated In 7 Graphic
DiagonalMatrix[list]
gives a matrix with the elements of list on the leading diagonal, and 0 elsewhere.
DiagonalMatrix[list, k]
gives a matrix with the elements of list on the k^(th) diagonal.
DiagonalMatrix[list, k, n]
pads with 0s to create an n×n matrix.
  • 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^(th) 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. »
New in 1 | Last modified in 7
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team