sum
Sum of array elements
Syntax
S= sum (A)
S= sum ( A, dim)
S = sum (___, type )
Description
returns the sum along different dimensions of theS
= sum (A
)fi
arrayA
.
IfA
is a vector,sum(A)
returns the sum of the elements.
IfA
is a matrix,sum(A)
treats the columns ofA
as vectors, returning a row vector of the sums of each column.
IfA
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 byS
= sum (___,type
)type
, using any of the input arguments in the previous syntaxes.type
can be'double'
or'native'
.
If
type
is'double'
, thensum
returns a double-precision array, regardless of the input data type.If
type
is'native'
, thensum
returns an array with the same class of input arrayA
.
Thefimath
object is used in the calculation of the sum. IfSumMode
isFullPrecision
,KeepLSB
, orKeepMSB
, then the number of integer bits of growth forsum(A)
isceil(log2(size(A,dim)))
.
sum
does not supportfi
objects of data typeBoolean
.