Main Content

reportInconsistency

Report inconsistent variable definitions

Since R2024a

    Description

    report = reportInconsistency(connectionObj) returns a dictionary object report that contains a list of variables visible to the data source connection connectionObj, that have multiple inconsistent definitions. Each entry in the dictionary maps a variable with inconsistent definitions to an array of structures that provide the value and metadata (for example name of data source) for each definition.

    report = reportInconsistency(connectionObj,varNames) returns the same information for specified variables varNames.

    example

    Examples

    collapse all

    Connect to a data dictionary and get an inconsistency report.

    dd = Simulink.data.connect("a.sldd");
    rpt = reportInconsistency(dd)
    r = 
    
    dictionary (string --> cell) with 2 entries
    
       "kp"         --> {1x3 struct array}
       "kb"         --> {1x2 struct array}
    

    Get an array of inconsistent definitions for the variable kb.

    rpt_kb = rpt("kb")
    
    rpt_kb = 
    
     1x2 struct array with fields:
    
        value
        metadata
    

    Get the value for the first definition of kb.

    rpt_kb(1).value
    
    ans = 
    
    1.5

    Get the metadata for the first definition of kb.

    rpt_kb(2).metadata
    
    dictionary (string --> cell) with 5 entries
    
        "DataSource"       --> {'a.sldd'}
        "Section"          --> {'Design Data'}
        "LastModified"     --> {'2023-Jun-04 02:34:37.530062'}
        "LastModifiedBy"   --> {'user'}
        "Status"           --> {'Unchanged'}
    

    Get the value for the second definition of kb.

    rpt_kb(2).value
    
    ans = 
    
    1.6

    The value is inconsistent with the first definition of kb.

    Get the metadata for the second definition of kb.

    rpt_kb(2).metadata
    
    dictionary (string --> cell) with 5 entries
    
        "DataSource"       --> {'ra.sldd'}
        "Section"          --> {'Design Data'}
        "LastModified"     --> {'2023-Jun-05 01:30:18.130062'}
        "LastModifiedBy"   --> {'user2'}
        "Status"           --> {'Unchanged'}
    

    Input Arguments

    collapse all

    Connection to data source, specified as a Simulink.data.DataConnection object.

    Variable names, specified by a string, character vector, string array, or cell array of character vectors.

    Output Arguments

    collapse all

    Report of inconsistent variable definitions, specified as a dictionary object. Each dictionary entry maps a variable name to an array of structures with value and metadata fields for each definition of the variable. The metadata in the structure is the same data provided by the getMetadata function.

    In these cases, the function returns a dictionary object with no entries:

    • A specified variable does not have multiple definitions.

    • The connected data source does not contain multiple definitions for variables.

    • For variables with multiple definitions, the definitions are consistent.

    • A specified variable does not exist in the connected data source.

    Version History

    Introduced in R2024a