Main Content

Enable Signal Logging for a Model

Enable and Disable Logging at the Model Level

To log a signal, mark it for logging. For details, see Configure a Signal for Logging.

Enable or disable logging globally for all signals that you mark for logging in a model. By default, signal logging is enabled. Simulink® logs signals if the Configuration Parameters > Data Import/Export > Signal logging parameter is checked. If the option is not checked, Simulink ignores the signal logging settings for individual signals.

When signals are marked for logging, the signal data logs to the workspace and to the Simulation Data Inspector. You can disable signal logging through the Configuration Parameters dialog box or programmatically.

  • In the Configuration Parameters dialog box, clear the Configuration Parameters > Data Import/Export > Signal logging parameter check box.

  • From the command line, use the SignalLogging parameter.


Selecting a Subset of Signals to Log

You can select a subset of signals to log for a model that has:

  • Signal logging enabled

  • Logged signals

For details, see Override Signal Logging Settings.

Specify Format for Dataset Signal Elements

Logged signal data is saved in Dataset format (as Simulink.SimulationData.Dataset objects). To specify whether you want the data for individual signals in the dataset to use MATLAB® timeseries or timetable elements, set the Dataset signal format configuration parameter. The default is timeseries. For details, see Dataset signal format.

Migrate Scripts That Use Legacy ModelDataLogs API

For scripts that simulate a model created in a release earlier than R2016a that uses ModelDataLogs format for logging, update the code to log in Dataset format.

If you have already logged signal data in the ModelDataLogs format, you can use the convertToDataset function to update the ModelDataLogs signal logging data to use Dataset format. For example, to update the older_model_dataset from ModelDataLogs format to Dataset format:

new_dataset = logsout.convertToDataset('older_model_data')

Converting a model from using ModelDataLogs format to using Dataset format can require that you modify your existing models and to code in callbacks, functions, scripts, or tests. The following table identifies possible issues to address after converting to Dataset format. The table provides solutions for each issue.

Possible Issue After Conversion to Dataset FormatSolution

Code in existing callbacks, functions, scripts, or tests that used the ModelDataLogs programmatic interface to access data can result in an error.

Check for code that uses ModelDataLogs format access methods. Update that code to use Dataset format access methods.

For example, suppose that existing code includes the following line:

logsout.('Subsystem Name')

Replace that code with a Dataset access method:


Mux block signal names are lost.

The Dataset format treats Mux block signals as a vector. To identify signals by signal names, replace Mux blocks with Bus Creator blocks.

Signal Viewer cannot be used for signal logging.

Simulink does not log signal logging data in the Signal Viewer.

Use the signal logging output variable to view the logged data.

The unpack method generates an error.

The unpack method, which is supported for Simulink.ModelDataLogs and Simulink.SubsysDataLogs objects, is not supported for Simulink.SimulationData.Dataset objects.

For example, if the data in mlog has three fields: x, y, and z, then:

For ModelDataLogs format data, the mlog.unpack method creates three variables in the base workspace.

For Dataset format data, access methods by names. For example:

x = logsout.getElement('x').Values

The ModelDataLogs and Dataset formats have different naming rules for unnamed signals.

If necessary, add signal names.

In ModelDataLogs format, for an unnamed signal coming from a block, Simulink assigns a name in this form:


For example, SL_Gain1.

In Dataset format, elements do not need a name, so Simulink leaves the signal name empty.

For both ModelDataLogs and Dataset formats, Simulink assigns the same name to unnamed signals that come from Bus Selector blocks.

Test points in referenced models are not logged.

Consider enabling signal logging for test points in a referenced model.

Script uses who or whos functions.

Consider using find instead.

Specify a Name for Signal Logging Data

You use the model-level signal logging name to access the signal logging data for a model. The default name for the signal logging data is logsout. Specifying a model-level signal logging name can make it easier to identify the source of the logged data. For example, you could specify the signal logging name car_logsout to identify the data as being the signal logging data for the car model.

To specify a different model-level signal logging name, use either of these approaches:

  • In the edit box next to the Configuration Parameters > Data Import/Export > Signal logging parameter, enter the signal logging name.

  • Use the SignalLoggingName parameter, specifying a signal logging name. For example:

    set_param(bdroot, 'SignalLoggingName', 'heater_model_signals')

Related Topics