Configuring the Matlab block

This section explains how to configure Matlab® function details, as well as input and output fields for your Matlab block.

Configuration for the block is split over the following tabs:

This configuration assumes that you have already set up Matlab® integration.

Note : If the Matlab MCR is not installed, it is not possible to open the Matlab block property page. If you attempt to open the property page when the Matlab MCR is not installed, a message is displayed in the Architect messages pane indicating that the "MWArray" file cannot be opened.

Matlab Tab

  1. Select a Matlab Assembly from the list of available Matlab assemblies located in the CSense Matlab repository.

    • Files that you will be using in this location must be valid .NET assemblies compiled using the correct version of the Matlab Compiler SDK to produce a 32-bit Windows .NET assembly. Files that do not meet these requirements are ignored.

  2. Select a Matlab assembly Function corresponding to a Matlab function from the list of available functions on the selected Matlab assembly.

    • Only functions that return a single array and take at least one array as a function parameter will be listed and supported.

    • Matlab functions listed must have this signature:  MWArray MyFunction(MWArray param1[, MWArray param2, ... ])

    • For example, you may select a function called FahrenheitToCelsius from the available Matlab assemblies that takes in one array of numeric values and returns another array of numeric values.

Inputs Tab

Map CSense input fields to Matlab function parameters as follows:

  1. On the top right of the dialog, select the Matlab function input parameter to which you will map the CSense input.

  2. Underneath that, specify the Matlab parameter type (Numeric or String).

    • If you specify a Numeric parameter type then:

      • Timestamps are converted to numeric OLE/Excel dates.

      • Qualities are converted to the raw numeric value of the integer OPC quality.

      • Values that are integers or doubles are converted to their equivalent numeric value. Values that are strings are converted to 0.

    • If you specify a String parameter type then:

      • Timestamps are converted to ISO 8601 extended strings in UTC.

      • Qualities are converted to "1" for good quality or "0" for bad quality.

      • Values are converted to their string representations.

  3. Build the array elements of the input parameter as follows, for each element:

    1. Select a field from the list of Available fields in the CSense block input port. All CSense field types are supported.

    2. In the Use field property section, select to use either the CSense field Timestamp, or the Value, or the Quality as an element in the selected function input parameter.  (In this way, a CSense field property may be mapped to multiple Matlab function input parameter elements.)

    3. You can reorder the items in the Selected area, to change the order of elements in the Matlab function input array parameter.

Outputs Tab

A CSense output field is created on the block output port for each element contained in the Matlab return array, using the following naming convention for output field names:  [output_field_prefix]_[xxxx],  where xxxx is an incrementing number (starting at 0001) to indicate the array element index. For example: FahrenheitToCelsius_0001, FahrenheitToCelsius_0002, FahrenheitToCelsius_0003, FahrenheitToCelsius_0004, etc.

Map Matlab function return results to CSense output fields as follows:

  1. Specify the Output field prefix.

  2. Specify the Output field count to indicate how many elements are expected in the array returned by the specified Matlab function.

    • Some Matlab functions return arrays of varying sizes. If you are using such a function, then the output field count should be set to an upper bound on the number of output fields expected. In such a case, if the number of elements returned by the function array is less than the number of configured output fields, your blueprint can use timestamps to determine whether a field value is for the current execute or a previous one.

    • The suffix always has at least 4 digits, but if you specify an output field count greater than 9999, then the suffix will have more than 4 digits for some of the fields.

  3. Specify the Output field data type, to indicate whether to create Double or String output fields.

Return to top


Related topics:

  

CSense 2023- Last updated: June 24,2025