sum — sum (row sum, column sum) of vector/matrix entries
y=sum(x) y=sum(x,'r') or y=sum(x,1) y=sum(x,'c') or y=sum(x,2) y=sum(x,'m')
For a vector or a matrix x
, y=sum(x)
returns
in the scalar y
the sum of all the entries of
x
.
y=sum(x,'r')
(or, equivalently, y=sum(x,1)
) is
the rowwise sum: y(j)= sum(x(:,j))
. y
is a row
vector
y=sum(x,'c')
(or, equivalently, y=sum(x,2)
) is
the columnwise sum. It returns in each entry of the column vector
y
the sum : y(i)= sum(x(i,:))
)).
y=sum(x,'m')
is the sum along the first non singleton
dimension of x
(for compatibility with Matlab).