Please enable JavaScript to view this site.

DAQFactory User's Guide

Navigation: 4 Expressions > 4.12 Expression Operator / Function Reference

4.12.8 Boxcar averaging and smoothing functions

Scroll Prev Top Next More

Boxcar functions:

Several boxcar averaging functions are available:

 

Boxcar(Value, Boxcar Size)

BoxcarSD(Value, Boxcar Size)

BoxcarMax(Value, Boxcar Size)

BoxcarMin(Value, Boxcar Size)

BoxcarSum(Value, Boxcar Size)

All do essentially the same thing.  They take a subset of the data in Boxcar Size sized chunks from value starting at index 0, and apply the appropriate function: Boxcar returns the mean of each of these chunks, SD the standard dev, etc.  The returned array has a size equal to the size of the original array divided by the boxcar size rounded up.  If the array size of value is not a multiple of boxcar size, then the last boxcar will have less then boxcar size elements used in its calculation.

Example:

Boxcar({1,4,2,6,7},2) returns {2.5,4,7}

2.5 is the average of 1 and 4

4 is the average of 2 and 6

7 is the average of 7.

For arrays with time, the result of the boxcar has the time of the last point in each car stored.  For BoxcarMax and BoxcarMin the time of the point in each car that is the max or min is stored instead.  This is very useful for plotting.

For example, assuming the MyChannel contained {1,4,2,6,7} with time associated with each data point then:

GetTime(BoxcarMin(MyChannel,2)) would return a three element array with the time of the 1, 2 and 7 data points.

Smoothing:

Smooth(Value, Amount):

Performs a running average.  The returned array is the same size as the value array.  Each element contains the average of the element and the next Amount-1 elements, unless the end of the array is reached.  As the end is approached and amount elements are not available, only the available elements are used in the average.  This results in a bit of roughness near the end of the array.

Example:

Smooth({1,4,2,6,7},2) returns {2.5,3,4,6.5,7}  

2.5 is the average of 1 and 4.

3 is the average of 4 and 2.

4 is the average of 2 and 6.

6.5 is the average of 6 and 7.

7 is the average of 7.