Skip to main content

sum

sum (waveName [, x1, x2])

The sum function returns the sum of the wave elements for points from x=x1 to x=x2.

Details

The X scaling of the wave is used only to locate the points nearest to x=x1 and x=x2. To use point indexing, replace x1 with "pnt2x(waveName,pointNumber1 )", and a similar expression for x2.

If x1 and x2 are not specified, they default to -inf and +inf, respectively.

If the points nearest to x1 or x2 are not within the point range of 0 to numpnts(waveName )-1, sum limits them to the nearest of point 0 or point numpnts(waveName)-1.

If any values in the point range are NaN, sum returns NaN.

Examples

Make/O/N=100 data; SetScale/I x 0,Pi,data
data=sin(x)
Print sum(data,0,Pi) // the entire point range, and no more
Print sum(data) // same as -infinity to +infinity
Print sum(data,Inf,-Inf) // +infinity to -infinity

The following is printed to the history area:

Print sum(data,0,Pi)      // the entire point range, and no more
63.0201
Print sum(data) // same as -infinity to +infinity
63.0201
Print sum(data,Inf,-Inf) // +infinity to -infinity
63.0201

See Also

mean, area, SumDimension