Sum of array elements

`S= sum (A)`

`S= sum ( A, dim)`

`S = sum (___ , type )`

returns
the sum along different dimensions of the `S`

= sum (`A`

)`fi`

array `A`

.

If `A`

is a vector, `sum(A)`

returns
the sum of the elements.

If `A`

is a matrix, `sum(A)`

treats
the columns of `A`

as vectors, returning a row vector
of the sums of each column.

If `A`

is a multidimensional array, `sum(A)`

treats
the values along the first non-singleton dimension as vectors, returning
an array of row vectors.

returns
an array in the class specified by `S`

= sum (___ , `type`

)`type`

, using
any of the input arguments in the previous syntaxes. `type`

can
be `'double'`

or `'native'`

.

If

`type`

is`'double'`

, then`sum`

returns a double-precision array, regardless of the input data type.If

`type`

is`'native'`

, then`sum`

returns an array with the same class of input array`A`

.

The `fimath`

object is used in the calculation
of the sum. If `SumMode`

is `FullPrecision`

, `KeepLSB`

,
or `KeepMSB`

, then the number of integer bits of
growth for `sum(A)`

is `ceil(log2(size(A,dim)))`

.

`sum`

does not support `fi`

objects
of data type `Boolean`

.

Was this topic helpful?