Main Content

resample

Resample OPC HDA data object to have defined time stamps

    Description

    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.

    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,InterpolationType) uses the specified InterpolationType.

    example

    Examples

    collapse all

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

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

    Display the values and qualities of the new object.

    newObj.showValues

    Input Arguments

    collapse all

    Raw OPC HDA data, specified as an OPC HDA data object.

    New timestamps, specified as a vector of datetime values returned by datetime function.

    Example: datetime(2018,11,30)

    Type of interpolation on the data in DObj, specified by one of these values:

    • 'linear': Linear interpolation.

    • 'hold': 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).

    • 'nearest': Nearest-neighbor interpolation as defined by interp1.

    • 'spline': Spline interpolation as defined by interp1.

    • 'pchip': Shape-preserving, piece-wise, cubic interpolation as defined by interp1.

    Output Arguments

    collapse all

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

    Version History

    Introduced before R2006a

    See Also

    Functions