Command Reference : Function Reference : Function Reference: G
  
 
@getmaindiagonal
Extract main diagonal from matrix.
Syntax: @getmaindiagonal(m)
m: matrix, vector, sym
Return: vector
Returns a vector created from the main diagonal of the matrix or sym object. The main diagonal is defined as the elements {(1, 1), (2, 2), ..., (k, k)} of the matrix, where k is the smaller of the number of rows and columns.
Examples
If M1 is an identity matrix, then
= @getmaindiagonal(m1)
returns an n-vector of ones.
Cross-references
See also @makediagonal.