主要内容

tsunion

R2026b

Union of timestamps in OPC UA data object

Description

newObj = tsunion(dObj) merges the timestamps of all node elements in data object dObj, so that each element of newObj has the same timestamp vector corresponding to all possible timestamps in all elements of dObj. When a node (element of the Data object) has no value corresponding to a timestamp, the function defines a value at that timestamp by linear interpolation or extrapolation.

If dObj contains elements with the same node name, the function combines those elements into one element. So the size of newObj can be smaller than the size of dObj.

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 = tsunion(dObj,interpolationType) uses the specified interpolationType.

example

Examples

collapse all

Load the OPC UA example data file and find the union of timestamps in uaDataVis.

load opcSampleUaData;
newObj = tsunion(uaDataVis);

Find the union using 'hold' resampling. Display the values and timestamps of the new object.

newObjHold = tsunion(uaDataVis, 'hold')
newObjHold = 

1-by-3 OPC UA Data object array:

         Timestamp                             Double                                       Float                                Int32                  
    -------------------  --------------------------------------------------  -----------------------------------  ------------------------------------  
    2015-04-22 09:00:02        2.000000 [Uncertain:Subnormal (Interpolated)]       10.000000 [Good (Raw)]                        10 [Good (Raw)]           
    2015-04-22 09:00:10       10.000000 [Good (Raw)]                               13.478261 [Good (Interpolated)]               13 [Good (Interpolated)]  
    2015-04-22 09:00:20       20.000000 [Good (Raw)]                               17.826086 [Good (Interpolated)]               18 [Good (Interpolated)]  
    2015-04-22 09:00:25       25.000000 [Good (Interpolated)]                      20.000000 [Good (Raw)]                        20 [Good (Raw)]           
    2015-04-22 09:00:28       28.000000 [Good (Interpolated)]                      25.000000 [Good (Raw)]                        25 [Good (Raw)]           
    2015-04-22 09:00:30       30.000000 [Good (Raw)]                               25.833334 [Good (Interpolated)]               26 [Good (Interpolated)]  
    2015-04-22 09:00:40       40.000000 [Bad (Raw)]                                30.000000 [Good (Raw)]                        30 [Good (Raw)]           
    2015-04-22 09:00:42       42.000000 [Good (Interpolated)]                       0.000000 [Bad (Raw)]                          0 [Bad (Raw)]            
    2015-04-22 09:00:48       48.000000 [Good (Interpolated)]                       4.000000 [Good (Raw)]                        40 [Good (Raw)]           
    2015-04-22 09:00:50       50.000000 [Good (Raw)]                               27.000000 [Good (Interpolated)]               45 [Good (Interpolated)]  
    2015-04-22 09:00:52       52.000000 [Good (Interpolated)]                      50.000000 [Good (Raw)]                        50 [Good (Raw)]           
    2015-04-22 09:01:00       60.000000 [Good (Raw)]                               54.000000 [Good (Interpolated)]               54 [Good (Interpolated)]  
    2015-04-22 09:01:10       70.000000 [Uncertain (Raw)]                          59.000000 [Good (Interpolated)]               59 [Good (Interpolated)]  
    2015-04-22 09:01:12       72.000000 [Good (Interpolated)]                      60.000000 [Good (Raw)]                        60 [Good (Raw)]           
    2015-04-22 09:01:17       77.000000 [Good (Interpolated)]                      70.000000 [Uncertain (Raw)]                   70 [Uncertain (Raw)]      
    2015-04-22 09:01:20       80.000000 [Good (Raw)]                               70.000000 [Good (Interpolated)]               70 [Good (Interpolated)]  
    2015-04-22 09:01:23       83.000000 [Good (Interpolated)]                      70.000000 [Good (Raw)]                        70 [Good (Raw)]           
    2015-04-22 09:01:26       86.000000 [Good (Interpolated)]                      80.000000 [Good (Raw)]                        80 [Good (Raw)]           
    2015-04-22 09:01:30       90.000000 [Good (Raw)]                               90.000000 [Good (Raw)]                        90 [Good (Raw)]           

Input Arguments

collapse all

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

Type of interpolation on the data in DObj, specified as 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