主要内容

load

Load data from MLDATX file to workspace

Since R2026a

    Description

    ds = load(mldatxFileObj,Name=Value) loads a subset of signals from the MLDATX file referenced by the mldatx.io.File object mldatxFileObj to the MATLAB® workspace as a Simulink.SimulationData.Dataset object. You must use a name-value argument to specify one or more filters for the subset of signals.

    example

    ds = load(mldatxSignalObj) loads data from the mldatx.io.Signal object mldatxSignalObj.

    example

    Examples

    collapse all

    Create an mldatx.io.File object referencing a saved MLDATX file. Then, get a list of signals in the MLDATX file by using listSignals on the object.

    myFileObj = mldatxfile("MyFile.mldatx");
    sigList = listSignals(myFileObj)
    sigList =
    
      3×6 table
    
          Name       RunIndex         Domain            BlockPath        BlockSubPath    PortIndex
        _________    ________    ________________    ________________    ____________    _________
    
        "rampSig"       1        "Outports"          "myModel/Out1"           ""             1    
        "sineSig"       2        "myModel/Record"    "myModel/Record"         ""             1    
        "rampSig"       2        "Outports"          "myModel/Out1"           ""             1    
    

    Load all signals named rampSig to the workspace using load.

    rampSigsDS = load(myFileObj,Name="rampSig")
    rampSigsDS = 
    
    Simulink.SimulationData.Dataset '' with 2 elements
    
                             Name     BlockPath    
                             _______  ____________ 
        1  [1x1 Signal]      rampSig  myModel/Out1
        2  [1x1 Signal]      rampSig  myModel/Out1
    
      - Use braces { } to access, modify, or add elements using index.
    

    The result is a two-element Simulink.SimulationData.Dataset object containing the logged rampSig data from the two runs in the MLDATX file. You can now access the data for further analysis using the variable name rampSigDS.

    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 load only the signals from a particular run. For example, load all the signals in the third run.

    mySigsThirdRun = load(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 technique used to log the 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, load the signals in the MLDATX file that were logged using the Record block.

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

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

    myFileObj = mldatxfile("MyFile.mldatx");

    You can load data for a subset of signals connected to a specific block using the block path. For example, load data for the signals connected to the output port of the Playback block in the model myModel.

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

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

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

    Create an mldatx.io.File object referencing a saved MLDATX file. Create a list of signals in the MLDATX file using listSignals.

    myFileObj = mldatxfile("MyFile.mldatx");
    sigList = listSignals(myFileObj)
    sigList =
    
      3×6 table
    
          Name       RunIndex         Domain            BlockPath        BlockSubPath    PortIndex
        _________    ________    ________________    ________________    ____________    _________
    
        "rampSig"       1        "Outports"          "myModel/Out1"           ""             1    
        "sineSig"       2        "myModel/Record"    "myModel/Record"         ""             1    
        "rampSig"       2        "Outports"          "myModel/Out1"           ""             1    
    

    Use the getSignals function to create an mldatx.io.Signal object for the signal in the first run.

    run1sig = getSignals(myFileObj,RunIndex=1);

    Load the signal to the workspace.

    run1sigDS = load(run1sig)
    run1sigDS = 
    
    Simulink.SimulationData.Dataset '' with 1 element
    
                             Name     BlockPath    
                             _______  ____________ 
        1  [1x1 Signal]      rampSig  myModel/Out1
    
      - Use braces { } to access, modify, or add elements using index.
    

    Create an mldatx.io.File object referencing a saved MLDATX file. Create a list of signals in the MLDATX file using the listSignals function.

    myFileObj = mldatxfile("MyFile.mldatx");
    sigList = listSignals(myFileObj)
    sigList =
    
      3×6 table
    
          Name       RunIndex         Domain            BlockPath        BlockSubPath    PortIndex
        _________    ________    ________________    ________________    ____________    _________
    
        "rampSig"       1        "Outports"          "myModel/Out1"           ""             1    
        "sineSig"       2        "myModel/Record"    "myModel/Record"         ""             1    
        "rampSig"       2        "Outports"          "myModel/Out1"           ""             1    
    

    Filter the signals to create an array of mldatx.io.Signal objects from the second run. Because the second run contains two signals, the getSignals function returns a 1-by-2 array of mldatx.io.Signal objects.

    run2sigs = getSignals(myFileObj,RunIndex=2);

    Load the signals to the workspace using signal indexing.

    run2Sig1DS = load(run2sigs(1))
    run2Sig1DS = 
    
    Simulink.SimulationData.Dataset '' with 1 element
    
                             Name     PropagatedName  BlockPath      
                             _______  ______________  ______________ 
        1  [1x1 Signal]      sineSig  sineSig         myModel/Record
    
      - Use braces { } to access, modify, or add elements using index.
    
    run2Sig2DS = load(run2sigs(2))
    run2Sig2DS = 
    
    Simulink.SimulationData.Dataset '' with 1 element
    
                             Name     BlockPath    
                             _______  ____________ 
        1  [1x1 Signal]      rampSig  myModel/Out1
    
      - Use braces { } to access, modify, or add elements using index.

    Input Arguments

    collapse all

    Reference to MLDATX file containing signals to load, specified as an mldatx.io.File object.

    Reference to the signal in an MLDATX file to load, specified as an mldatx.io.Signal object.

    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: rampSigsDS = load(myFileObj,Name="rampSig")

    Filter Options

    expand all

    Signal name to specify for import, specified as a string or character vector.

    The Name filter option can be combined only with the RunIndex filter option and the signal name search options MatchCase and WholeWord.

    By default, when you use the Name option, the function loads all signals with partially matching names, regardless of case.

    ds = load(mldatxFileobject,Name="mysig")
    ds = 
    
    Simulink.SimulationData.Dataset '' with 4 elements
    
                             Name      BlockPath     
                             ________  _____________ 
        1  [1x1 Signal]      mysig     untitled/Out1
        2  [1x1 Signal]      mySig1    untitled/Out2
        3  [1x1 Signal]      mysignal  untitled/Out3
        4  [1x1 Signal]      mySignal  untitled/Out4
    
      - Use braces { } to access, modify, or add elements using index.
    

    To filter by whole names or matching capitalization, also include the WholeWord or MatchCase name-value arguments. For example, load only the signals whose names contain mysig with matching capitalization.

    ds = load(mldatxFileobject,Name="mysig",MatchCase=true)
    
    ds = 
    
    Simulink.SimulationData.Dataset '' with 2 elements
    
                             Name      BlockPath     
                             ________  _____________ 
        1  [1x1 Signal]      mysig     untitled/Out1
        2  [1x1 Signal]      mysignal  untitled/Out3
    
      - Use braces { } to access, modify, or add elements using index.
    
    >> 

    Example: filteredSigs = load(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

    The Domain filter option can be combined only with the RunIndex filter option.

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

    The BlockPath filter option can be combined 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.

    The SubPath filter option can be combined with the BlockPath, PortIndex, and RunIndex filter options.

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

    The PortIndex filter option can be combined with the BlockPath, SubPath, and RunIndex filter options.

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

    The RunIndex filter option can be combined with all other filter options.

    Signal Name Search Options

    expand all

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

    This name-value argument can be used only in combination with the Name, BlockPath, and SubPath filter options.

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

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

    This name-value argument can be used only in combination with the Name, BlockPath, and SubPath filter options.

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

    Output Arguments

    collapse all

    Loaded data, returned as a Simulink.SimulationData.Dataset object containing one or more Simulink.SimulationData.Signal objects.

    Version History

    Introduced in R2026a