diag

Matlab Functions List


  • D = diag(v) returns a square diagonal matrix with the elements of vector v on the main diagonal
  • D = 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 A
  • x = diag(A,k) returns a column vector of the elements on the kth diagonal of A