FUNCTION REFERENCE
trace
Sum of a square matrix's diagonal.
Sum of a square matrix's diagonal.
Syntax
trace(A)Returns one scalar. Real, complex and logical square arrays are accepted; logical values convert to double. A nonsquare input raises an error.
Example
trace([1 2;3 4]) % 5Differences from MATLAB: none known; a complex sum with zero imaginary part is real.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.