<< NaN Constructors functions eps >>

diag


Get diagonal elements of matrix or create diagonal matrix.


Syntax


D = diag(V)
X = diag(A)
D = diag(V, k)
X = diag(A, k)

Input argument


V

Diagonal elements

A

Input matrix

Output argument


D

vector

X

matrix

Description


diag returns diagonal elements of matrix or create diagonal matrix.

Example


diag(eye(3))
diag(diag(eye(3)))

See also


ones.

History


Version Description
1.0.0 initial version

Author


Allan CORNET

<< NaN Constructors functions eps >>