imat_fn/sum


Purpose

Sum of functions.

Syntax

g=sum(f)
g=sum(f,2)
g=sum('all')
g=sum(f,[1 2])

Description

G = sum(F) is the sum of the functions of the vector F. If F is a matrix, G is a row vector with the sum over each column. For N-D arrays, sum(F) operates along the first non-singleton dimension.

G = sum(F,'all') sums all elements of F.

G = sum(F,DIM) sums along the dimension DIM.

G = sum(F,VECDIM) operates on the dimensions specified in the vector VECDIM. For example, sum(F,[1 2]) operates on the elements contained in the first and second dimensions of F.

SUM checks the abscissas and ordinate dimensions for each subset of functions to sum. If any of these do not match, an error will occur. SUM also warns you if the functions have inconsistent function types. It does not check any other properties such as ordinate type, so it is up to you to ensure that the summation makes sense.