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.

Native MATLAB Data Types from Read Operations

The default format of returned data is an M-by-1 OPC HDA data object containing data values whose type is defined by the OPC variant type the server stored it as. In some cases, such as readAtTime and readProcessed, you can specify that the read operations return data in native MATLAB® data types, including structures and cell arrays.

For example, you can request the same set of data in the following ways.

Request Structure Output

In this case, the read operation returns a single output containing four fields:

struct =  HDAObject.readAtTime('Random.Int1', TimeStamps, 'struct')
struct = 
       ItemID: 'Random.Int1'
    Timestamp: [8x1 double]
      Quality: [8x1 double]
        Value: [8x1 int8]

Request MATLAB Numeric Data Output

When you request MATLAB numeric types as output, the read operation returns four outputs: Item ID, Value, Quality, and TimeStamp. The Value output is converted into the MATLAB data type requested. The following example returns all Value data as unsigned 32-bit integers:

[itmId, val, Q, ts] = HDAObject.readAtTime('Random.Int1', TimeStamps, 'uint32');

Request Cell Array Output

When requesting cell array output, the read operation returns four outputs: Item ID, Value, Quality, and TimeStamp. The Value output is a cell array, preserving the original data type of the item on the server.

[cItemId, cVal, cQ, cTimes] = HDAObject.readAtTime('Random.Int1', TimeStamps, 'cell')
Was this topic helpful?