Skip to main content
MedCalc
Mail a PDF copy of this page to:
(Your email address will not be added to a mailing list)
working
Show menu Show menu

DIAG matrix function

Description

DIAG(A) Creates a diagonal matrix. The matrix argument can be either a numeric square matrix or a vector.

If matrix A is a square matrix, the DIAG function creates a column vector with its elements er equal to the corresponding diagonal elements er,r of A.

If matrix A is a vector, the DIAG function creates a matrix with diagonal elements er,r that are the values er in the vector. All off-diagonal elements are zeros.

Examples

DIAG({1,9,8}) returns {1,0,0|0,9,0|0,0,8}

DIAG({1,9,8|1,2,7|6,8,3}) returns {1|2|3}

DIAG(DIAG({1,9,8|1,2,7|6,8,3})) returns {1,0,0|0,2,0|0,0,3}

Calculator

DIAG(  

See also