diagSum
Compute the diagonal sum of a matrix
Contents
Syntax
- total=diagSum(A);
Description
total=diagSum(A) returns the diagonal sum of a square matrix A.
If the dimension of A is mxm, the return row vector is of length 2*m-1.
Example
A=magic(3) diagSum(A)
A =
8 1 6
3 5 7
4 9 2
ans =
4 12 15 8 6