Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

pracma (version 0.5-3)

mtrace: Matrix trace

Description

Sum of the main diagonal elements.

Usage

mtrace(a)

Arguments

a
a square matrix

Value

  • scalar value

Details

Sums the elements of the main diagonal of areal or complrx square matrix.

See Also

mdiag, diag

Examples

Run this code
mtrace(matrix(1:16, nrow=4, ncol=4))

Run the code above in your browser using DataLab