@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

vector v1 = @getmaindiagonal(m1)

vector v2 = @getmaindiagonal(s1)

Cross-references