I have a matrix of order n say M. If I do sum(M) I would get the a vector in which all the entries would give me the sum of elements of each row of M.

How can I find the sum of all elements of M?

1 | initial version |

I have a matrix of order n say M. If I do sum(M) I would get the a vector in which all the entries would give me the sum of elements of each row of M.

How can I find the sum of all elements of M?

I have a matrix of order n say M. If I do sum(M) I would get the a vector in which all the entries would give me the sum of elements of each row of M.

How can I find the sum of all elements of ~~M?~~M?
Does there exist any command which can return the sum of all elements of a matrix?

Please help me out.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.