trace

Navigation:  Language Reference > Functions > Matrix >

trace

Previous pageReturn to chapter overviewNext page

Syntax

y = trace(A);

Description

Returns the sum of the diagonal elements of the matrix A.

Examples

A = [1,2,3;4,ramp(1),6];

y = trace(A);

Limitations

y must be a scalar.