MEAN_2D_ARRAY_LREAL block

Short summary

Name

MEAN_2D_ARRAY_LREAL

→POU type

→function

Category

IEC-block, NumericEnh, block with internal error diagnostic

Conform to →IEC-standard

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/add.svg not defined in IEC-standard

Graphical interface

images/download/thumbnails/414782018/MEAN_2D_ARRAY_LREAL-version-1-modificationdate-1535032387573-api-v2.png

Available since

  • version 1.45.0 (for logi.CAD 3) – initial variant

  • version 2.0.9 (for library Standard) – graphical interface with in-out variable

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

→Data type

Description

In-outs
(VAR_IN_OUT):

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

  • mean value

  • 0.0 in case of an error or if M or N = 0

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.