Read Historical Data Over a Time Range

The readRaw function allows you to request the value, quality, and timestamp data for a list of items over a specified time domain. Define the time domain by indicating start and end times for the sampling. This function returns all data stored on the historian within the given time range.

By default, historians return the first data point found from the start time specified, up to the data point found just before the end time. By setting the optional 'bounds' parameter to true, you can indicate that bounding values be included. The server then returns data at the start and end times. If no data exists at those exact times, the server returns the data value that is closest to that time but outside the time range specified.

This function is useful if you want to retrieve raw values from the server, and processes that data using MATLAB® rather than relying on the server to perform the processing for you.

For example, if you are interested in the values between 17 November 2010 and 18 November 2010 in the 'Int2' items under the 'Random' branch of an OPC HDA server, and you were interested in retrieving the bounding values, use this code:

DataObject = ReadRaw(HdaClient, 'Random.Int2', ...
       datenum(2010,11,17), datenum(2010,11,18), TRUE)

To read values at specified time stamps use the readAtTime function. If you are reading large amounts of data and will be aggregating that data, consider using readProcessed (if your server supports that function).

Was this topic helpful?