|MATLAB Function Reference|
Sum of array elements
B = sum(A)
returns sums along different dimensions of an array.
A is a vector,
sum(A) returns the sum of the elements.
A is a matrix,
sum(A) treats the columns of
A as vectors, returning a row vector of the sums of each column.
A is a multidimensional array,
sum(A) treats the values along the first non-singleton dimension as vectors, returning an array of row vectors.
B = sum(A,dim)
sums along the dimension of
A specified by scalar
sum(diag(X)) is the
The magic square of order 3 is
This is called a magic square because the sums of the elements in each column are the same.
as are the sums of the elements in each row, obtained by transposing: