S = sum(A) returns
the sum of the elements of A along the first array dimension whose
size does not equal 1:

If A is a vector, then sum(A) returns
the sum of the elements.

If A is a nonempty, nonvector matrix,
then sum(A) treats the columns of A as
vectors and returns a row vector whose elements are the sums of each
column.

If A is an empty 0-by-0 matrix,
then sum(A) returns 0, a 1-by-1
matrix.

If A is a multidimensional array,
then sum(A) treats the values along the first array
dimension whose size does not equal 1 as vectors and returns an array
of row vectors. The size of this dimension becomes 1 while
the sizes of all other dimensions remain the same.

S = sum(___,type) accumulates
in and returns an array in the class specified by type,
using any of the input arguments in the previous syntaxes. type can
be 'double' or 'native'.

Dimension to operate along, specified as a positive integer
scalar. If no value is specified, the default is the first array dimension
whose size does not equal 1.

Consider a two-dimensional input array, A:

sum(A,1) works on successive elements
in the columns of A and returns a row vector of
the sums of each column.

sum(A,2) works on successive elements
in the rows of A and returns a column vector of
the sums of each row.

Output class, specified as 'double' or 'native',
defines the data type that the operation is performed in and returned
in.

If type is 'double',
then sum computes and returns a double-precision
array, regardless of the input data type. For example, if A is single,
then sum accumulates in and returns in double.
This is the default behavior for integer data types when type is
not specified.

If type is 'native', sum accumulates
natively and returns an array with the same data type as the input
array A. For example, if A has
data type int8, then sum(A,'native') accumulates
in and returns in int8. This is the default behavior
for single and double data types
when type is not specified.