This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Extract Diagonal

Extract main diagonal of input matrix


Math Functions / Matrices and Linear Algebra / Matrix Operations



The Extract Diagonal block populates the unoriented output vector with the elements on the main diagonal of the M-by-N input matrix A.

D = diag(A)					Equivalent MATLAB code

The output vector has length min(M,N).

Supported Data Types

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed and unsigned)

  • Boolean — Block outputs are always Boolean.

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

See Also

Create Diagonal MatrixDSP System Toolbox
Extract Triangular MatrixDSP System Toolbox

Introduced before R2006a

Was this topic helpful?