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, thensum(A)
returns the sum of the elements. - If
A
is a matrix, thensum(A)
returns a row vector containing the sum of each column. - If
A
is a multidimensional array, thensum(A)
operates along the first array dimension whose size does not equal 1, treating the elements as vectors. This dimension becomes1
while the sizes of all other dimensions remain the same.
S = sum(A
,dim
)
returns the sum along dimension dim
. For example, if A
is a matrix, then sum(A,2)
is a column vector containing the sum of each row.S = sum(___,outtype
)
returns the sum with a specified data type, using any of the input arguments in the previous syntaxes. outtype
can be 'default'
,'double'
, or 'native'
.S = sum(___,nanflag
)
specifies whether to include or omit NaN
values from the calculation for any of the previous syntaxes. sum(A,'includenan')
includes all NaN
values in the calculation while sum(A,'omitnan')
ignores them.
No comments:
Post a Comment