answer = sum(matrix) answer = sum(structure)
Returns the sum of all the elements of a matrix or a structure.
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
trace, diag