David
Farruggio

MathGenie

sum

Sum of array elements

Syntax and Description

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 matrix, then sum(A) returns a row vector containing the sum of each column.
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.

Back to functions