trace — trace
trace(X)
real or complex square matrix, polynomial or rational matrix.
trace(X) is the trace of the matrix X.
X
Same as sum(diag(X)).
sum(diag(X))
A=rand(3,3); trace(A)-sum(spec(A))