주요 콘텐츠

resample

R2026b

Resample OPC UA data object to have defined timestamps

    Description

    newObj = resample(dObj,newTimestamp) resamples data in OPC UA data object dObj so that all elements of the object have the timestamps given by newTimestamp.

    If dObj contains elements with the same node name, 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,newTimestamp,interpolationType) uses the specified interpolationType.

    example

    Examples

    collapse all

    Load the OPC UA example data file and resample the first element of uaDataSample. Display the values and qualities of the new object.

    load opcSampleUaData;
    timeRange = datetime(2025,6,1,9,30,0:10:60);
    fixedPoint = datetime(0, 1, 0);
    newTS = days(timeRange - fixedPoint);
    newObj = resample(uaDataSample(1),newTS,'spline')
    newObj = 
    
    1-by-1 OPC UA Data object array:
    
             Timestamp                             Counter                        
        -------------------  ---------------------------------------------------  
        2025-06-01 09:30:00         -7398352 [Uncertain:Subnormal (Interpolated)]  
        2025-06-01 09:30:10         -7398364 [Uncertain:Subnormal (Interpolated)]  
        2025-06-01 09:30:20         -7398377 [Uncertain:Subnormal (Interpolated)]  
        2025-06-01 09:30:30         -7398389 [Uncertain:Subnormal (Interpolated)]  
        2025-06-01 09:30:40         -7398401 [Uncertain:Subnormal (Interpolated)]  
        2025-06-01 09:30:50         -7398414 [Uncertain:Subnormal (Interpolated)]  
        2025-06-01 09:31:00         -7398426 [Uncertain:Subnormal (Interpolated)]  

    Input Arguments

    collapse all

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

    New timestamps, specified as a vector of date numbers.

    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 timestamps. Any timestamp 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 UA data returned as an array of OPC UA data objects. Each column in the array corresponds to one node.

    Version History

    Introduced before R2006a

    See Also

    Functions