Main Content

filterByQuality

R2026b

Filter OPC UA data by quality characteristics

    Description

    newObj = filterByQuality(dObj,qualityID) returns the data values from dObj whose quality matches the qualityID.

    example

    newObj = filterByQuality(dObj,Name=Value) filters data by quality category using one or more name-value arguments. Specify Major, Substatus, or Origin to filter by specific quality characteristics. Only values whose quality matches all specified categories are returned.

    example

    Examples

    collapse all

    Load the OPC UA example data file and examine the uaDataVis object.

    load opcSampleUaData
    summary(uaDataVis)
    1-by-3 OPC UA Data object:
    
         Name        Value          Start Timestamp       End Timestamp          Quality      
        ------  ----------------  -------------------  -------------------  ------------------
        Double  9 double values   2015-04-22 09:00:10  2015-04-22 09:01:30  3 unique qualities
        Float   12 single values  2015-04-22 09:00:02  2015-04-22 09:01:30  3 unique qualities
        Int32   12 int32 values   2015-04-22 09:00:02  2015-04-22 09:01:30  3 unique qualities

    The values in the data object are of different qualities. Extract the data with quality 'Good'.

    newDataObj = filterByQuality(uaDataVis,'Good')
    newDataObj = 
    
    1-by-3 OPC UA Data object:
    
         Name        Value          Start Timestamp       End Timestamp                Quality           
        ------  ----------------  -------------------  -------------------  -----------------------------
        Double  7 double values   2015-04-22 09:00:10  2015-04-22 09:01:30  1 unique quality [Good (Raw)]
        Float   10 single values  2015-04-22 09:00:02  2015-04-22 09:01:30  1 unique quality [Good (Raw)]
        Int32   10 int32 values   2015-04-22 09:00:02  2015-04-22 09:01:30  1 unique quality [Good (Raw)]

    Load the OPC UA data file and resample the data in uaDataVis. The resampled data contains interpolated values in addition to the original raw values.

    load opcSampleUaData
    dUnion = tsunion(uaDataVis);
    summary(dUnion)
    1-by-3 OPC UA Data object:
    
         Name        Value            Start Timestamp           End Timestamp            Quality
        ------  ----------------  -----------------------  -----------------------  ------------------
        Double  13 double values  2015-04-22 09:00:02.000  2015-04-22 09:01:30.000  5 unique qualities
        Float   13 single values  2015-04-22 09:00:02.000  2015-04-22 09:01:30.000  4 unique qualities
        Int32   13 int32 values   2015-04-22 09:00:02.000  2015-04-22 09:01:30.000  4 unique qualities

    Filter the resampled data to keep only values with good quality and raw origin, removing the interpolated values introduced by tsunion.

    goodRawData = filterByQuality(dUnion,Major='good',Origin='raw');
    summary(goodRawData)
    1-by-3 OPC UA Data object:
    
         Name        Value            Start Timestamp           End Timestamp                  Quality
        ------  ----------------  -----------------------  -----------------------  -----------------------------
        Double  7 double values   2015-04-22 09:00:10.000  2015-04-22 09:01:30.000  1 unique quality [Good (Raw)]
        Float   10 single values  2015-04-22 09:00:02.000  2015-04-22 09:01:30.000  1 unique quality [Good (Raw)]
        Int32   10 int32 values   2015-04-22 09:00:02.000  2015-04-22 09:01:30.000  1 unique quality [Good (Raw)]

    Input Arguments

    collapse all

    OPC UA data, specified as an array of OPC UA Data objects.

    Quality of OPC UA node data, specified as a character vector or cell array of character vectors. The quality ID can be 'Good', 'Bad', or 'Uncertain'.

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: filteredData = filterByQuality(dObj,Major={'good','uncertain'},Substatus='limited',Origin={'raw','interpolated'})

    Major quality status, specified as a character vector or cell array of character vectors.

    Data Types: char | cell

    Data substatus, specified as a character vector or cell array of character vectors.

    Data Types: char | cell

    Data origin, specified as a character vector or cell array of character vectors.

    Data Types: char | cell

    Output Arguments

    collapse all

    OPC UA data, returned as an OPC UA data object array. newObj contains only the data values whose quality matches the specified qualityID.

    Version History

    Introduced in R2015b

    See Also

    Functions