Main Content


Read raw data of specified time range from HDA server



DObj = readRaw(HdaClient,ItmList,StartTime,EndTime) reads data from the items defined by ItmList, stored on the OPC HDA server connected to OPC HDA client HdaClient, between StartTime (inclusive) and EndTime (exclusive). The StartTime and EndTime arguments must be date numbers, or character vectors that can be converted to a MATLAB® date number. DObj is returned as an opc.hda.Data array, with one element per item specified in ItmList.

DObj = readRaw(HdaClient,ItmList,StartTime,EndTime,ExtendedBounds) allows you to specify boundary extension. If ExtendedBounds is true, then the first data point on or outside the defined start and end times is returned. If ExtendedBounds is false, then only values that were timestamped between StartTime (inclusive) and EndTime (exclusive) are included.

One or more timestamps returned for each item can be unique to that item. To retrieve aligned data from an OPC HDA server, use readAtTime or readProcessed.


collapse all

Read data over the past day from two items in the OPC HDA server.

Create an OPC HDA client and connect the client to the server.

hdaObj = opchda('localhost','Matrikon.OPC.Simulation');

Read the last day’s data from two specified items.

DObj = readRaw(hdaObj,{'Random.Real8','Random.Real4'},now-1,now);

Input Arguments

collapse all

OPC HDA client, specified as an OPC HDA client object.

Example: opchda()

HDA items, specified as a character vector, string, or supporting array of either.

Example: {'Random.Real8','Random.Real4'}

Data Types: char | string | cell

Time boundaries, specified as serial date numbers. The values can be doubles, such as values returned by the datenum or now functions, or character vectors that can be converted to date numbers.

Example: datenum(2018,11,30)

Data Types: double | char

Extend time boundaries to assure inclusion of start and end times, specified as false or true.

This flag instructs the historical server whether to completely span the required start and end time, or return only values that are contained within the specified start and end time (start time included but not end time). If ExtendedBounds is true, the returned values are guaranteed to include the timestamp at or before the specified start time, and at or after the specified end time. If ExtendedBounds is false, there is no guarantee that the values include the exact specified start time, and definitely do not include the specified end time. The rules applied by this flag are:

  • If ExtendedBounds is false (default), the server returns all recorded data from the start time up to, but not including, the end time.

  • If ExtendedBounds is true, the server returns all data from the start time up to (and including) the end time. If no data value exists exactly at the start time, the previous value is returned; if no data value exists exactly at the end time, the next value is be returned; even if these values are outside the specified start and end times.

  • If ExtendedBounds is true and no data exists on the start time or before it, the server includes a value of Empty at the start timestamp, and a quality of OPCHDA_NOBOUND (“No Bound”). Similarly for the end time.

Example: true

Data Types: logical

Output Arguments

collapse all

Raw OPC HDA data returned as an array of OPC HDA data objects, with one element per item.

Version History

Introduced in R2011a