MEAN_2D_ARRAY_LREAL block
Short summary
Name |
MEAN_2D_ARRAY_LREAL |
→POU type |
|
Category |
|
Conform to →IEC-standard |
not defined in IEC-standard |
Graphical interface |
|
Available since |
|
Functionality
The block returns the arithmetic mean of all values of an a rray with 2 dimensions entered at input A. Only the first M rows and N columns are considered. The array must contain at least M rows and N columns.
The result might be inaccurate when using the block with large LINT or ULINT values.
Inputs, return value
|
Identifier |
Description |
|
In-outs |
A |
ARRAY [*,*] OF REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT(corresponds to →generic data type ANY_NUM) |
variable-length array |
Inputs: |
M |
UINT |
number of rows to consider |
N |
UINT |
number of columns to consider |
|
Return value: |
– |
LREAL |
|
Input EN and output ENO are available when →calling
the block. See "Execution control: EN, ENO" for information on input EN and output ENO.
Internal error diagnostic for block
The block checks whether the size of the array for A contains at least M rows and N columns. If this is not the case, the output ENO of the block is set to value FALSE (or an equivalent).
Example for usage within ST-editor
FUNCTION_BLOCK ExampleMean2DArray
VAR
inputArray : ARRAY [1..2, -1..1] OF LINT := [2( [1, 2, 3])];
result1, result2 : LREAL;
enoCheck1, enoCheck2 : BOOL;
END_VAR
result1 := MEAN_2D_ARRAY_LREAL(A := inputArray, M := 2, N := 3, ENO => enoCheck1);
// 'result1' evaluates to value '2.0'. 'enoCheck1' evaluates to 'TRUE'.
ENO := AND(result1 = 2.0, enoCheck1);
result2 := MEAN_2D_ARRAY_LREAL(A := inputArray, M := 3, N := 2, ENO => enoCheck2);
// 'enoCheck2' evaluates to 'FALSE' because 'inputArray' has only 2 rows.
// 'result2' evaluates to '0.0'.
ENO := AND(ENO, result2 = 0.0, NOT(enoCheck2));
END_FUNCTION_BLOCK
When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.