Determining Range Values and Coercing Data in Arrays

Complete the following steps to determine if each value in an array falls within a range specified by the upper limit and lower limit inputs and optionally to coerce the values to fall within the range.

Note  The following steps use numeric values as an example. You can determine if a value in an array of strings or an array of Boolean values falls within a range and optionally coerce the value to fall within the range. Refer to Appendix C, Comparison Functions, in the LabVIEW User Manual for more information about using data types in Comparison functions.
  1. Select the In Range and Coerce function located on the Functions»Comparison palette and place it on the block diagram.
  2. Right-click the In Range and Coerce function and select Compare Elements from the shortcut menu.
  3. Wire an array to the x input of the function.
  4. Wire the maximum value for the range in the upper limit input of the function. If a value in x is greater than this value, the function converts the number to the upper limit. The default value is positive infinity.
  5. Wire the minimum value for the range in the lower limit input of the function. If a value in x is less than this value, the function converts the number to the upper limit. The default value is positive infinity.

    Note  You can wire a scalar value or an array of numbers to either upper limit or lower limit. If you wire a scalar to upper limit or lower limit, each element in the array x is checked against the scalar limit. If you wire an array to upper limit or lower limit, each element in the array you wire to x is checked against the corresponding element in the array wired as a limit.

  6. Run the VI. The function returns an array of numbers in the coerced output. If each element is within the range set by the upper limit and lower limit inputs, the value is unchanged. If the element is not in range, it is converted to either the upper limit or lower limit.

    Also, the In Range output of the In Range and Coerce function returns an array of Boolean values. Each Boolean value in the array corresponds to an element in the array wired to x and indicates if the numeric element is within the specified range.