Main Content

OPC UA Components


Industrial Communication Toolbox™ provides an OPC UA client to connect to OPC UA servers. Using the client, you connect to the server, query server status, browse the server namespace, read and write current values, and read historical values from nodes on the server. Historical data is retrieved as OPC data objects, which allow you to process historical data in preparation for common analysis tasks.

OPC UA Client

You construct the OPC UA client using the opcua function. You set the security configuration for the connection using setSecurityModel. You connect the client to the server using connect, optionally passing user authentication credentials. The client includes a number of properties describing the server capabilities, including supported security models and user authentication options. See for more information on the properties available to the client. You can also query the server for extended status information using getServerStatus.

You use the client to perform any communication with the server, including browsing the server name space, reading and writing current values, and reading historical values from the server.


The OPC UA client includes a Namespace property, which contains the top level of the server’s namespace as an array of Nodes. An OPC UA Node variable describes the node on the server, and contains other subnodes in the Children property. Nodes have a NodeType which can be 'Object' or 'Variable' or 'Method'. Object nodes have no value associated with them, and are used purely for organizing the namespace of the server. Variable nodes store current values, representing a sensor or actuator value associated with the server. Method nodes represent function calls to object, which can be invoked to execute object specific processes. For more information, see

Servers can choose to historize nodes (store previous data values for that node). The Historizing property of a Node defines whether a server is historizing the node or not. If you try to retrieve historical data from a Variable node with Historizing set to false, no data is returned and an error is displayed.

You can read and write current values, and retrieve historical data, using Node variables directly. This is simply a short-hand for performing the same operations on the node Client property.


Data retrieved from OPC UA servers includes three important values. The Value is accompanied by a Quality and a Timestamp. The Quality represents how accurately the data Value is considered to reflect the actual source value attached to the server. The Timestamp represents the time that the server recorded the value, or received notification from the data source that the value is current.

When you retrieve current values, the Value, Quality, and Timestamp are retrieved into separate arrays. When you retrieve historical values, OPC UA servers might return a different number of Value, Quality, and Timestamp arrays for each Node requested. This data is packaged into an OPC UA Data object, which allows you to process this data set in preparation for common analysis tasks. For more information, type


For an example of working with OPC UA data, see Visualize and Preprocess OPC UA Data.

OPC UA Quality

OPC UA Quality values are 32-bit integer values. OPC UA Qualities encode many different characteristics of the quality of the data returned from a current or historical data read operation, including the Major quality (Good, Uncertain, or Bad), quality substatus (dependent on Major quality), value limits (High Limit, Low Limit, Constant), and history origin and characteristics (Raw, Interpolated, Calculated). You can query these characteristics individually using functions specific to the Quality variable that is returned in the read operation. For more information, type


Working with Time in OPC UA

OPC UA servers return timestamps for server status and for all current and historical read operations. The timestamp represents the time at which the server recorded the data value returned in the read operation. Timestamps are represented in MATLAB® by datetime values. The datetime values are always returned in the time zone of the MATLAB client used to retrieve the data from the OPC UA server. OPC UA historical read functions require time ranges or specific timestamp arrays over which to retrieve historical data. You can specify time ranges using MATLAB datetime values, or as MATLAB date numbers. Any numeric value passed as a timestamp is interpreted as a MATLAB date number. For functions requiring a start and end timestamp, you can also pass a start timestamp and a duration.