Documentation

Access Signal Logging Data

View Signal Logging Data

You can view the signal logging data for a paused or completed simulation, using one of these interfaces:

  • The Simulation Data Inspector

  • Programmatically, using MATLAB® commands

To access signal logging data programmatically, the approach you use depends on the signal logging data format (Dataset or ModelDataLogs). For details, see:

    Note:   If you do not see logging data for a signal that you marked in the model for signal logging, check the logging configuration using the Signal Logging Selector. Use the Signal Logging Selector to enable logging for a signal whose logging is overridden. For details, see View the Signal Logging Configuration and Override Signal Logging Settings.

Signal Logging Object

Simulink® saves signal logging data in a signal logging object, which you access using a MATLAB workspace variable.

The type of the signal logging object depends on the signal logging format that you choose. For details, see Specify the Signal Logging Data Format.

  • Dataset format — Uses a Simulink.SimulationData.Dataset object

  • ModelDataLogs format — Uses a Simulink.ModelDataLogs object

The default name of the signal logging variable is logsout. You can change the variable name. For details, see Specify a Name for the Signal Logging Data for a Model.

View Logged Signal Data with the Simulation Data Inspector

You can use the Simulation Data Inspector to view logged signal data.

To view logged signal data with the Simulation Data Inspector, open the Simulink Editor and use one of the following approaches:

  • To display logged signals when a simulation ends or when you pause a simulation, select Simulation > Output > Send Logged Workspace Data to Data Inspector.

  • To launch the Simulation Data Inspector to display the logged data, select Simulation > Output > Simulation Data Inspector.

For additional information about using the Simulation Data Inspector, see Inspect Signal Data with Simulation Data Inspector.

Handling Spaces and Newlines in Logged Names

Signal names in data logs can have spaces or newlines in their names when:

  • The signal is named and the name includes a space or newline character.

  • The signal is unnamed and originates in a block whose name includes a space or newline character.

  • The signal exists in a subsystem or referenced model, and the name of the subsystem, Model block, or of any superior block, includes a space or newline character.

The following three examples show a signal whose name contains a space, a signal whose name contains a newline, and an unnamed signal that originates in a block whose name contains a newline:

The following example shows how to handle spaces or new lines in logged names, if a model uses:

  • Dataset for the signal logging format

  • The default of logsout for the signal logging data

logsout
logsout = 

  Simulink.SimulationData.Dataset
  Package: Simulink.SimulationData

  Characteristics:
              Name: 'logsout'
    Total Elements: 3

  Elements:
    1: ''
    2: 'x  y'
    3: 'a
b'

To access a signal with a space or newline, use the index. For example, to access the x y signal:

>> logsout.getElement(2)

Programmatically Access Logged Signal Data Saved in ModelDataLogs Format

    Note:   The ModelDataLogs signal logging format is supported for backward compatibility. For new models, use the Dataset format.

For information on extracting signal data from that object, see Simulink.ModelDataLogs.

Was this topic helpful?