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 only 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 is logged to the workspace and also sent directly to the Simulation Data Inspector, by default. You can disable logging signals to the workspace 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
Data for signals marked for logging is always sent to the Simulation Data Inspector.
You can select a subset of signals to log for a model that has:
Signal logging enabled
For details, see Override Signal Logging Settings.
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®
timetable elements, set the
Dataset signal format configuration parameter. The default is
timeseries. For details, see Dataset signal format.
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
If you have already logged signal data in the
format, you can use the
function to update the
ModelDataLogs signal logging data to use
Dataset format. For example, to update the
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 Format||Solution|
Code in existing callbacks, functions, scripts, or tests that used the
Check for code that uses
For example, suppose that existing code includes the following line:
that code with a
Mux block signal names are lost.
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.
example, if the data in
If necessary, add signal names.
Test points in referenced models are not logged.
Consider enabling signal logging for test points in a referenced model.
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
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
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.
SignalLoggingName parameter, specifying a signal logging
name. For example:
set_param(bdroot, 'SignalLoggingName', 'heater_model_signals')