Skip to content

Array avg

Type Function: REAL

Input PT Pointer (pointer to the array)
SIZE UINT (size of the array)
Output REAL (mean value of the array)
The function _ARRAY_AVG calculates the median value of an arbitrary array ofREAL. When called, a pointer to the array and its size in bytes is passed to the function. Under CoDeSys the call reads ARRAY_AVG(ADR(Array), SIZEOF(Array)), where array is the name of the array to be manipulated. ADR() is a standard function which identifies the pointer to the array and SIZEOF() is a standard function, which determines the size of the array. In order to determine the maximum, the array referenced by the pointer is scanned directly in memory. The function ARRAY_AVG does not change the content of the array.
This type of processing arrays is very efficient because no additional memory is required and no surrender values must be copied.

array_avg

Example:

ARRAY_AVG(ADR(bigarray), SIZEOF (bigarray))