Main Content


Resample OPC HDA data object to have defined time stamps


NewObj = resample(DObj,NewTS)
NewObj = resample(DObj,NewTS,'linear')
NewObj = resample(DObj,NewTS,'hold')
NewObj = resample(DObj,NewTS,'nearest')
NewObj = resample(DObj,NewTS,'spline')
NewObj = resample(DObj,NewTS,'pchip')


NewObj = resample(DObj,NewTS) resamples data in OPC HDA data object DObj so that all elements of the object have the time stamps given by NewTS. NewTS must be a vector of MATLAB® date numbers.

If DObj contains elements with the same item ID, those elements are combined into one element. So the size of NewObj might be smaller than the size of DObj.

Values are linearly interpolated or extrapolated to the new time stamps.

Quality for the resampled data is set as follows:

  • All original values retain their quality.

  • All interpolated values get a quality of Interpolated: Good.

  • All extrapolated values get a quality of Interpolated: Sub-Normal.

NewObj = resample(DObj,NewTS,'linear') uses linear interpolation.

NewObj = resample(DObj,NewTS,'hold') uses a zero-order hold interpolation where the previous known value is used for all new time stamps. Any time stamp prior to the first known value is set to NaN (or 0 if the value is a fixed-point data type).

NewObj = resample(DObj,NewTS,'nearest') uses nearest-neighbor interpolation as defined by interp1.

NewObj = resample(DObj,NewTS,'spline') uses spline interpolation as defined by interp1.

NewObj = resample(DObj,NewTS,'pchip') uses shape-preserving, piece-wise, cubic interpolation as defined by interp1.


Load the OPC HDA example data file and resample the first element of hdaDataSmall.

load opcSampleHdaData;
newTS = datenum(2010,6,1,9,30,0:10:60);
newObj = resample(hdaDataSmall(1),newTS);

Display the values and qualities of the new object.


See Also