Skip to content
Prev 44739 / 398528 Next

quesion on diag of matrix

On Mon, 2004-02-23 at 18:53, li xian wrote:
If 'm' is your matrix:

sum(diag(m))

See ?sum and ?diag, the latter of which will extract the diagonal of the
matrix. 

Be sure to read the help for diag() fully for some of the usage caveats.

HTH,

Marc Schwartz