Main Content

getMetadata

Get metadata for variable or connected data source

Since R2024a

    Description

    metadata = getMetadata(connectionObj) returns the metadata (for example, the name of the data source) for the connected data source connectionObj. The metadata provided depends on the type of connected data source.

    example

    metadata = getMetadata(connectionObj,varName) returns the metadata (for example, date last modified) for the variable varName and its connected data source connectionObj.

    If the data connection can see multiple definitions of the same variable (for example, in a data dictionary and in a referenced dictionary), the function returns an array that contains metadata for each definition.

    Examples

    collapse all

    dd = Simulink.data.connect("myDictionary.sldd");
    md = getMetadata(dd,"x")
    md = 
    
    dictionary (string --> cell) with 5 entries
    
        "Source"                --> {'myDictionary.sldd'}
        "Section"               --> {'Design Data'}
        "LastModified"          --> {'2023-Jun-04 02:34:37.530062'}
        "LastModifiedBy"        --> {'user'}
        "Status"                --> {'Unchanged'}
        "isArchitecturalData"   --> {0}
    

    Input Arguments

    collapse all

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

    Variable name, specified by a string or character vector.

    Output Arguments

    collapse all

    Metadata for variable and its data source, specified by a dictionary object or an array of dictionary objects. The metadata provided depends on the type of connected data source.

    Metadata for Base Workspace

    Property NameValue
    Source'base workspace'
    Section''

    Metadata for MAT file

    Property NameValue
    SourceMAT file name
    Section''

    Metadata for Model Workspace

    Property NameValue
    SourceModel name
    Section'model workspace'
    DataSource'Model File' | 'MATLAB code' | 'MAT File' | 'MATLAB File'
    ExternalFileExternal file that stores or creates variables
    isModelArgument (when the function specifies a variable name argument)boolean

    Metadata for Data Dictionary (variable name specified)

    Property NameValue
    SourceName of data dictionary
    Section'Design Data'
    LastModifiedstring
    LastModifiedBystring
    Statusstring
    isArchitecturalDataboolean — true when the variable corresponds to an entry in the Architectural Data or DDS Libraries sections, and false otherwise.
    ArchitecturalObject (when the variable corresponds to an entry in the Architectural Data section)Name of data object
    DDSObject (when the variable corresponds to an entry in the DDS Libraries section)Name of data object

    Metadata for Data Dictionary (no variable name specified)

    Property NameValue
    Section'Design Data'
    filepathstring
    DataSourcescell array of data dictionary references
    HasAccessToBaseWorkspaceboolean
    EnableAccessToBaseWorkspaceboolean
    HasUnsavedChangesboolean
    NumberOfEntriesinteger

    Version History

    Introduced in R2024a