How to do sum of diagonal element of a matrix?
Show older comments
from what i know to do sum of diagonal element of a matrix is by:
tr(A)
but it says
Undefined function or method 'tr' for input arguments of type 'double'.
so i think i should do it manually by using the 'diag(A)'.. but...how i'm going to do 'sum of diag(A)' ?
Answers (2)
Azzi Abdelmalek
on 8 Aug 2015
trace(A)
Walter Roberson
on 8 Aug 2015
sum(diag(A))
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!