FUNCTION REFERENCE

sum

Sum of elements.

Sum of elements.

Syntax

sum(A)

Returns the sum of each column, or one value for a row vector. Logical input is allowed.

Example

sum([1 2 3])   % 6

Differences from MATLAB: No 'all', type or NaN options. The sum of [] is 0. Complex input sums the real and imaginary parts with the real kernel and gives a real result when every imaginary part is zero.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.