y = sum(X)
y = sum(X), where X is a matrix, returns a row y vector with the sum over each column. If X is a vector, y is the sum of the elements of X.
This is called a magic square because the sum of the elements in each column is the same.M = magic(3)M =8 1 63 5 74 9 2
And the sum of the elements in each row, which can be obtained by transposing twice, is the same.sum(M) =15 15 15
sum(M')' =151515
cumsum,prod,trace
(c) Copyright 1994 by The MathWorks, Inc.