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.
set_param(bdroot,'SignalLogging','off')
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.
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.
ModelDataLogs
APIFor 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
function to update the
Simulink.ModelDataLogs.convertToDataset
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 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: logsout.('Subsystem Name').X.data Replace
that code with a logsout.getElement('x').Values.data |
Mux block signal names are lost. | The |
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 | The For
example, if the data in For For
|
The | If necessary, add signal names. In
For
example, In For both
|
Test points in referenced models are not logged. | Consider enabling signal logging for test points in a referenced model. |
Script uses | Consider using |
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')