Lets have matrix A say A = magic(100);. I have seen 2 ways of computing sum of all elements of matrix A.

sumOfA = sum(sum(A));

Or

sumOfA = sum(A(:));

Is one of them faster (or better practise) then other? If so which one is it? Or are they both equally fast?

Edit
Report