Main Content

getSignals

R2026b

Create interface to individual signals in MLDATX file

Since R2026a

    Description

    sigSubset = getSignals(mldatxFileObj) creates an interface to each signal saved in an MLDATX file. Use this interface to select signals for loading.

    getSignals returns an array of mldatx.io.Signal objects where each mldatx.io.Signal object acts as an interface to a signal in the MLDATX file referenced by the mldatx.io.File object mldatxFileObj.

    example

    sigSubset = getSignals(mldatxFileObj,Name=Value) creates an interface to a subset of signals that match the filter options specified by the name-value arguments.

    example

    Examples

    collapse all

    Create an mldatx.io.File object referencing a saved MLDATX file. The mldatx.io.File object is an interface to the MLDATX file as a whole.

    myFileObj = mldatxfile("MyFile.mldatx");

    To interact with the individual signals in an MLDATX file, you can create a separate interface for each signal in an MLDATX file. To create an array of mldatx.io.Signal objects that each reference a signal in the MLDATX file, use the mldatx.io.File object as input to the getSignals function.

    allSigs = getSignals(myFileObj);
    allSigs.Name
    ans =
    
        'sineSig'
    
    ans =
    
        'rampSig'
    
    
    ans =
    
        'constSig'
    
    

    Use allSigs with load to import data from these signals.

    Create an mldatx.io.File object referencing a saved MLDATX file.

    myFileObj = mldatxfile("MyFile.mldatx");

    Create an interface to the signals in the MLDATX file with names that contain mysig. By default, results are case-insensitive and need not be the whole word.

    mySigs = getSignals(myFileObj,Name="mysig");
    mySigs.Name
    ans =
    
        'mysig'
    
    
    ans =
    
        'mysignal'
    
    
    ans =
    
        'mySig1'
    
    
    ans =
    
        'mySignal'

    To filter signals with whole-word or case-sensitive matching, use the WholeWord or MatchCase name-value arguments. For example, filter the results to include only the signals with matching capitalization.

    mySigsCaseMatch = getSignals(myFileObj,Name="mysig",MatchCase=true);
    mySigsCaseMatch.Name
    ans =
    
        'mysig'
    
    
    ans =
    
        'mysignal'

    Create an mldatx.io.File object referencing a saved MLDATX file.

    myFileObj = mldatxfile("MyFile.mldatx");

    An MLDATX file can contain data from multiple simulation runs. Use the RunIndex filter option to create an interface to only the signals from a particular run. For example, return all the signals in the third run.

    mySigsThirdRun = getSignals(myFileObj,RunIndex=3)

    Create an mldatx.io.File object referencing a saved MLDATX file.

    myFileObj = mldatxfile("MyFile.mldatx");

    Simulink.sdi.Signal objects have metadata that specifies the origin of the logged signal such as signal logging, Outport blocks, or the Record block. You can filter signals in the MLDATX file based on the logging origin. For example, return the signals in the MLDATX file that were logged using the Record block.

    mySigs = getSignals(myFileObj,Domain="Record")

    Create an mldatx.io.File object referencing a saved MLDATX file.

    myFileObj = mldatxfile("MyFile.mldatx");

    You can get an interface to subset of signals connected to a specific block using the block path. For example, get an interface to the signals connected to the output port of the Playback block in the model myModel.

    mySigsPlayback = getSignals(myFileObj,BlockPath="myModel/Playback");
    

    You can combine the BlockPath filter option with the SubPath and PortIndex filters. For example, get an interface to the signal connected to the second port of the Playback block.

    mySigPlayback2 = getSignals(myFileObj,BlockPath="myModel/Playback",PortIndex=2);
    

    Input Arguments

    collapse all

    Reference to MLDATX file that contains the signals to filter, specified as an mldatx.io.File object created with mldatxfile.

    Name-Value Arguments

    expand 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: mySigsThirdRun = getSignals(myFileObj,RunIndex=3)

    Filter Options

    expand all

    Signal name to filter by, specified as a string or character vector.

    By default, when you use the Name option, the subset of filtered signals includes all signals with partially matching names, regardless of case.

    filteredSigs = getSignals(mldatxFileObject,Name="mysig");
    filteredSigs.Name
    ans =
    
        'mysig'
    
    
    ans =
    
        'mysignal'
    
    
    ans =
    
        'mySig1'
    
    
    ans =
    
        'mySignal'
    

    To further narrow down the signals to load, you can combine the Name filter option with the RunIndex filter option and the signal name search options MatchCase and WholeWord. For example, get only the signal whose whole name is mysig.

     filteredSigs = getSignals(mldatxFileObject,Name="mysig",WholeWord=true);
    >> filteredSigs.Name
    ans =
    
        'mysig'

    Example: filteredSigs = getSignals(myFileObj,Name="mySigName",MatchCase=true,WholeWord=true)

    Logging domain of signal to filter by, specified as a string or character vector such as one of these options:

    • "Signals" — Signal logging data

    • "Outports" — Output logging data

    • "States" — States logging data

    • "Data Store Memory" — Data store memory logging data

    • "Parameters" — Logged parameter data

    • "Stateflow" — Stateflow® data

    • "Simscape" — Simscape™ data

    • "Assessments" — Simulink® Test™ assessment data

    • "Profiling" — Execution profiling data

    You can combine the Domain filter option only with the RunIndex filter option.

    Block path of logged signal, specified as a string or character vector.

    You can combine the BlockPath filter option with the SubPath, PortIndex, and RunIndex filter options.

    Component of block containing logged data, specified as a string or character vector. For example, if the block path refers to a Stateflow chart, you can use SubPath to filter results by chart signals.

    You can combine the SubPath filter option with the BlockPath, PortIndex, and RunIndex filter options.

    Output port index of logged signal, specified as a positive integer.

    You can combine the PortIndex filter option with the BlockPath, SubPath, and RunIndex filter options.

    Index of run that contains the logged signal, specified as a positive integer.

    You can combine the RunIndex filter option with all other filter options.

    Signal Name Search Options

    expand all

    Option to return only case-sensitive matches, specified as true or false.

    You can use this name-value argument only in combination with the Name, BlockPath, and SubPath filter options.

    Example: filteredSigs = getSignals(myFileObj,Name="mySigName",MatchCase=true)

    Option to return only whole word matches, specified as true or false.

    You can use this name-value argument only in combination with the Name, BlockPath, and SubPath filter options.

    Example: filteredSigs = getSignals(myFileObj,Name="mySigName",WholeWord=true)

    Output Arguments

    collapse all

    Interface to subset of signals saved in an MLDATX file, returned as an mldatx.io.Signal object or an array of mldatx.io.Signal objects.

    Version History

    Introduced in R2026a