メインコンテンツ

Data

R2026b

Create OPC UA Data object

    Description

    An opc.ua.Data object represents historical data retrieved from OPC UA nodes. When you retrieve historical values, OPC UA servers might return a different number of Value, Quality, and Timestamp arrays for each node. This data is packaged into an OPC UA data object, which allows you to process this data for common analysis tasks.

    Creation

    You can construct OPC UA data objects using the readHistory, readAtTime, or readProcessed functions of an OPC UA client.

    Properties

    expand all

    Name of the node, represented as a character vector.

    Example:

    >> dataObj.Name
    
    ans =
    
        'Sinusoid'

    Timestamp of data read from node, represented as a datetime vector of timestamps. Timestamps represent the time that the source provided the data to the server. The OPC UA server always returns the datetime values in the time zone of the MATLAB® client used to retrieve the data.

    Example:

    >> dataObj.Timestamp
    
    ans = 
    
      6×1 datetime array
    
       30-Apr-2026 00:00:00
       30-Apr-2026 02:00:00
       30-Apr-2026 04:00:00
       30-Apr-2026 06:00:00
       30-Apr-2026 08:00:00
       30-Apr-2026 10:00:00

    Value of data read from nodes, represented as a vector of data values.

    Example:

    >> dataObj.Value
    
      ans = 6×1
              1.7321
              1.9021
              1.9890
              1.9890
              1.9021
              1.7321

    Quality of data read from nodes, represented as a cell array of OPC UA qualities.

    Example:

    >> dataObj.Quality
    
    ans =
    
      6×1 cell array
    
        {'Good (Calculated)'}
        {'Good (Calculated)'}
        {'Good (Calculated)'}
        {'Good (Calculated)'}
        {'Good (Calculated)'}
        {'Good (Calculated)'}

    Object Functions

    summaryDisplay summary of OPC UA data object
    stairsPlot OPC UA data in stairstep graph
    plot Plot OPC UA data in line graph
    tableConvert OPC data object to a table
    tsintersectIntersection of timestamps in OPC UA data object
    tsunionUnion of timestamps in OPC UA data object
    arrayHasSameTimeStampVerify if all elements in OPC UA data object have same timestamp
    appendCombine OPC data objects
    resampleResample OPC UA data object to have defined timestamps
    singleConvert OPC UA data object array to single matrix
    doubleConvert OPC UA data object array to double matrix
    int8Convert OPC UA data object array to int8 matrix
    int16Convert OPC UA data object array to int16 matrix
    int32Convert OPC UA data object array to int32 matrix
    int64Convert OPC UA data object array to int64 matrix
    uint8Convert OPC UA data object array to uint8 matrix
    uint16Convert OPC UA data object array to uint16 matrix
    uint32Convert OPC UA data object array to uint32 matrix
    uint64Convert OPC UA data object array to uint64 matrix
    logicalConvert OPC UA data object array to logical matrix
    filterByQualityFilter OPC UA data by quality characteristics
    getIndexFromNameReturn OPC data with matching names

    Examples

    collapse all

    Create an OPC UA client and connect it to the server.

    uaClnt = opcua("localhost",62550);
    connect(uaClnt);

    Construct a node object using index and identifier values.

    uaNode =opcuanode(3,1005,c);

    Retrieve data for the current day.

    dataObj = readHistory(uaClnt,uaNode,datetime('today'),datetime('now'));

    Summarize and plot retrieved data.

    summary(dataObj);
    1-by-1 OPC UA Data object:
    
          Name          Value           Start Timestamp       End Timestamp                Quality           
        --------  ------------------  -------------------  -------------------  -----------------------------
        Sinusoid  1000 double values  2026-03-27 00:00:01  2026-03-27 00:16:40  1 unique quality [Good (Raw)]
    plot(dataObj);

    Plot of Sinusoid node data

    Version History

    Introduced in R2015b