sum

Type: External

Group: matrix

Syntax

answer = sum(matrix)
answer = sum(structure)

Description

Returns the sum of all the elements of a matrix or a structure.

Examples

sum([1,2;3,4]) = 10
sum([1,2,3;4,5,6]) = 21
x=struct(a, 1, b, 2, c, 3) = a = 1 : b = 2 : c = 3 :
sum x = 6

See Also

trace, diag