trace
Sum of diagonal elements.
Syntax
Section titled “Syntax”b = trace(A)Description
Section titled “Description”Returns the sum of the diagonal elements of A. Equivalent to sum(diag(A)). Defined for square and non-square matrices alike (sum runs along min(size(A))).
Examples
Section titled “Examples”trace(magic(3)) % 15trace(eye(5)) % 5