writeValue (opcua)

Write values to nodes on OPC UA server



writeValue(UaClient,NodeList,Values) writes content of Values, to the nodes identified by NodeList. You can browse for node objects using browseNamespace. You can also create nodes using opcuanode.

If NodeList is a single node, then Values is the value written to the node. If NodeList is an array of nodes, Values must be a cell array the same size as NodeList, and each element of the cell array is written to the corresponding element of NodeList.

The data type of the value you are writing does not need to match the node’s ServerDataType property. All values are automatically converted before writing to the server. However, a warning or error is generated if the data type conversion fails. For DateTime data types, you can pass a MATLAB datetime or a number; any numeric value can be interpreted as a MATLAB datetime.


For a node with a numeric ServerDataType, you can write only a scalar value, not an array.

writeValue(NodeList,Values) writes content of Values, to the nodes identified by NodeList. All nodes must be of the same connected client.


collapse all

Write a value to a node selected with the name space browser.

s = opcuaserverinfo('localhost');
UaClient = opcua(s);
Node = browseNamespace(UaClient); % Select a variable node

Input Arguments

collapse all

OPC UA client specified as an OPC UA client object. The client must be connected.

List of nodes specified as an array of node objects or a single node. For information on node object functions and properties, type:

help opc.ua.Node

Values specified as a cell array or single value. If writing to a single node, use one value; if writing to an array of nodes, use a cell array of values.

Introduced in R2015b