Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

writeValue (opcua)

Write values to nodes on OPC UA server

Syntax

writeValue(UaClient,NodeList,Values)
writeValue(NodeList,Values)

Description

example

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.

Note

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.

Examples

collapse all

This example shows how to write to a node selected with the name space browser.

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

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

Was this topic helpful?