diag
D = diag(v)returns a square diagonal matrix with the elements of vector v on the main diagonalD = diag(v,k)places the elements of vector v on the kth diagonal- k=0 represents the main diagonal
- k>0 is above the main diagonal
-
- k<0 is below the main diagonal
x = diag(A)returns a column vector of the main diagonal elements of Ax = diag(A,k)returns a column vector of the elements on the kth diagonal of A