Main Content

Simulink.ModelDataLogs

(Not recommended) Access signal data logs for data logged using ModelDataLogs format

    The ability to log and load data using the ModelDataLogs format has been removed. Use another supported format, such as Dataset format, instead. For more information, see Compatibility Considerations.

    Description

    The Simulink.ModelDataLogs object contains all data logged from simulation in a model that logs data using the ModelDataLogs format.

    Creation

    Prior to R2016a, you could configure a model to log data using the ModelDataLogs format. Simulating a model with the Signal logging format parameter set to ModelDataLogs created a Simulink.ModelDataLogs object that contained the data for all logged signals. You could specify the name for the ModelDataLogs object using the Signal logging name parameter.

    Properties

    expand all

    Logged Data Properties

    The Simulink.ModelDataLogs object contains properties with the signal data logged from simulation. The number, type, and names of the properties that contain logged data depend on the structure of the model and the logging configuration.

    Property Name SourceLogged Data SourceValue
    Model nameTop model or model referenceSimulink.ModelDataLogs
    Subsystem nameSubsystemSimulink.SubsysDataLogs
    Signal nameSignalSimulink.Timeseries
    Mux or virtual bus nameMux or virtual busSimulink.TSArray
    Bus objectNonvirtual busSimulink.TSArray

    The hierarchy of ModelDataLogs and SubsysDataLogs objects in a ModelDataLogs object matches the hierarchy of the model. The hierarchy of a Simulink.TSArray object for a bus matches the bus hierarchy.

    Model Properties

    Model or Model block name, returned as a character vector. For the top model, the Name property value is the name of the model. For a referenced model, the Name property value is the name of the Model block that references the model.

    Object Functions

    convertToDataset(Not recommended) Convert data logged using ModelDataLogs format to Dataset format
    unpack(Not recommended) Extract signal data from ModelDataLogs, SubsysDataLogs, or TSArray object into workspace variables
    who(Not recommended) List names of objects inside ModelDataLogs, SubsysDataLogs, or TSArray object
    whos(Not recommended) List name and type of objects inside ModelDataLogs, SubsysDataLogs, or TSArray object

    Examples

    collapse all

    Property names in a ModelDataLogs object can have spaces or new line characters when a logged signal:

    • Has a name that includes a space or new line character

    • Is unnamed and originates in a block with a name that includes a space or new line character

    • Exists in a subsystem or referenced model, and the name of the subsystem, Model block, or of any upstream block in the model hierarchy includes a space or new line character

    This model logs signals with names that include spaces or new line characters.

    A model that contains three Sine Wave blocks connected to output ports with three signals marked for logging.

    logsout
    logsout =
     
    Simulink.ModelDataLogs (model_name):
      Name                   Elements  Simulink Class
    
      ('x y')                   1      Timeseries
      ('a
    b')                   1      Timeseries
      ('SL_Sine
    Wave1')         1      Timeseries

    You cannot access elements of the ModelDataLogs object by using tab completion or by typing the name after a dot. The MATLAB® parser interprets the space or new line character as a separator between identifiers. For example, this code results in an error.

    logsout.x y
    
    ??? logsout.x y
                  |
    Error: Unexpected MATLAB expression.

    To access an element with a name that includes a space, enclose the name in single quotes.

    logsout.('x y')
           Name: 'x y'
         BlockPath: 'model_name/Sine'
         PortIndex: 1
        SignalName: 'x y'
        ParentName: 'x y'
          TimeInfo: [1x1 Simulink.TimeInfo]
              Time: [51x1 double]
              Data: [51x1 double]

    To access an element with a name that includes a new line character, construct the element name by concatenating a new line character in the appropriate location.

    cr=sprintf('\n')
    logsout.(['a' cr 'b'])

    Version History

    Introduced before R2006a

    expand all