This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this 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?