Override Signal Logging Settings
Benefits of Overriding Signal Logging Settings
As you develop a model, you may want to override the signal logging settings for a specific simulation run. You can override signal logging properties without changing the model in the Simulink® Editor.
To reduce memory overhead and to facilitate the analysis of simulation logging results, override signal logging properties. By overriding signal logging settings, you can avoid recompiling a model.
Overriding signal logging properties is useful when you want to:
Focus on only a few signals by disabling logging for most of the signals marked for logging. You can mark a superset of signals for logging, and then select different subsets of them for logging.
Exclude a few signals from the signal logging output.
Override specific signal logging properties, such as decimation, for a signal.
Collect only what you need when running multiple test vectors.
Two Interfaces for Overriding Signal Logging Settings
Use either of two interfaces to override signal logging settings:
You can use a combination of the two interfaces. The Signal Logging Selector creates
Simulink.SimulationData.ModelLoggingInfo
objects when saving the override settings. The command-line interface has properties whose
names correspond to the Signal Logging Selector interface. For example, the
Simulink.SimulationData.ModelLoggingInfo
object has a
LoggingMode
property, which corresponds to the Logging
Mode parameter in the Signal Logging Selector.
Scope of Signal Logging Setting Overrides
When you override signal logging settings, Simulink uses those override settings when you simulate the model.
Simulink saves in the model the signal logging override configuration that you specify. However, Simulink does not change the signal logging settings in the Signal Properties dialog box for each signal in the model.
In the Signal Logging Selector, if you override some signal logging settings, and then
set the Logging Mode to Log all signals as specified in
model
, the logging settings defined in the model appear in the Signal
Logging Selector. The override settings are greyed out, indicating that you cannot override
these settings. To reactivate the override settings, set Logging Mode
to Override signals
. Using the Signal Logging Selector to
override logging for a specific signal does not affect the signal logging indicator for that
signal.
If you close and then reopen the model, the logging setting overrides that you made are in effect, if logging mode is set to override signals for that model. When the model displays the signal logging indicators, it displays the indicators for all logged signals, including logged signals that you have overridden.
Note
The software rebuilds a model in the following situation:
The model contains one or more signals marked for signal logging.
You simulate the model in rapid accelerator mode.
You use the Signal Logging Selector or MATLAB® command line to modify the signal logging configuration.
You simulate the model in rapid accelerator mode again.
Override Signal Logging Settings with Signal Logging Selector
Open the Signal Logging Selector.
In the Configuration Parameters > Data Import/Export pane, click the Configure Signals to Log button.
Tip
To enable the Configure Signals to Log button, select the Signal logging configuration parameter.
Set Logging Mode to
Override signals
.Note
The
Override signals
setting affects all levels of the model hierarchy. This setting can result in turning off logging for any signal throughout the hierarchy, based on existing settings. To review settings, select the appropriate node in the Model Hierarchy pane.View the node containing the logged signals that you want to override. If necessary, expand nodes or configure the Model Hierarchy pane to display masked subsystems. See View Logging Configuration Using the Signal Logging Selector.
Override signal logging settings. Use one of the following approaches, depending on whether your model uses model referencing:
Tip
To open the Configuration Parameters > Data Import/Export pane from the Signal Logging Selector, use the button.
Models Without Model Referencing: Overriding Signal Logging Settings
If your model does not use model referencing (that is, the model does not include any Model blocks), override signal logging settings using the following procedure.
Open the Signal Logging Selector. In the Configuration Parameters > Data Import/Export pane, click the Configure Signals to Log button.
If necessary, select Signal logging to enable the Configure Signals to Log button.
Set Logging Mode to
Override signals
.View the node containing the logged signals that you want to override. If necessary, expand nodes or configure the Model Hierarchy pane to display masked subsystems. See View Logging Configuration Using the Signal Logging Selector.
In the Contents pane table, select the signal whose logging settings you want to override.
Override logging settings:
To disable logging for a signal, clear the
DataLogging
check box for that signal.To override other signal logging settings (for example, decimation), ensure that the
DataLogging
check box is selected. Then, edit values in the appropriate columns.
Models with Model Referencing: Overriding Signal Logging Settings
If your model uses model referencing (that is, the model includes at least one Model block), override signal logging settings using one or more of these procedures:
Enable Logging for All Logged Signals. By default, Simulink logs all the logged signals in a model, including the logged signals throughout model reference hierarchies.
If logging is disabled for any logged signals in the top-level model or in the top-level Model block in a model reference hierarchy, then in the Model Hierarchy pane, the check box to the left of that node is:
Solid (
), if logging is disabled for some of signals.
Empty (
), if logging is disabled for all the signals.
To enable logging of all logged signals for a node:
Open the Signal Logging Selector. In the Configuration Parameters > Data Import/Export pane, click the Configure Signals to Log button.
Set Logging Mode to
Override signals
.View the node containing the logged signals that you want to override. If necessary, expand nodes or configure the Model Hierarchy pane to display masked subsystems. See View Logging Configuration Using the Signal Logging Selector.
In the Model Hierarchy pane, select the check box to the left of the node, so that the check box has a check mark (
).
For the top-level model, logging is enabled for all logged signals in the top-level model, but not for logged signals in model reference hierarchies.
For a Model block at the top of a model referencing hierarchy, logging is enabled for the whole model reference hierarchy for the selected referenced model.
Disable Logging for All Signals in Node. If signal logging is enabled for any signals in a model node, then in the Model Hierarchy pane, the check box to the left of the node is:
Solid (
), if logging is enabled for some signals.
Checked (
), if logging is enabled for all signals.
To disable logging for all logged signals in a node of a model:
Open the Signal Logging Selector. In the Configuration Parameters > Data Import/Export pane, click the Configure Signals to Log button.
Set Logging Mode to
Override signals
.View the node containing the logged signals that you want to override. If necessary, expand nodes or configure the Model Hierarchy pane to display masked subsystems. See View Logging Configuration Using the Signal Logging Selector.
In the Model Hierarchy pane, clear the check box to the left of the node, so that the check box is empty (
).
For the top-level model, logging is disabled for all logged signals in the top-level model, but not for logged signals in model reference hierarchies.
For a Model block at the top of a model referencing hierarchy, logging is disabled for the whole model reference hierarchy for the selected referenced model.
Override Signal Logging for a Subset of Signals. To log some, but not all, logged signals in a model node:
Open the Signal Logging Selector. In the Configuration Parameters > Data Import/Export pane, click the Configure Signals to Log button.
Set Logging Mode to
Override signals
.View the node containing the logged signals that you want to override. If necessary, expand nodes or configure the Model Hierarchy pane to display masked subsystems. See View Logging Configuration Using the Signal Logging Selector.
In the Model Hierarchy pane, ensure that the check box for the top-level model or Model block is either solid (
), if logging is disabled for some of the signals, or empty (
), if logging is disabled for all the signals. Click the check box to cycle through different states.
In the Contents pane table, for the signals that you want to log, select the check box in the
DataLogging
column.To enable logging for multiple signals, hold the Shift or Ctrl key and select a range of signals or individual signals. Select the check box in the
DataLogging
column of one of the highlighted signals.
Override Other Signal Logging Properties. In addition to overriding the setting for the DataLogging
property for a signal, you can override other signal logging properties, such as
decimation.
Open the Signal Logging Selector. In the Configuration Parameters > Data Import/Export pane, click the Configure Signals to Log button.
Set Logging Mode to
Override signals
.View the node containing the logged signals that you want to override. If necessary, expand nodes or configure the Model Hierarchy pane to display masked subsystems. See View Logging Configuration Using the Signal Logging Selector.
In the Model Hierarchy pane, ensure that the check box for the top-level model or Model block is solid (
) if logging is disabled for some signals, or empty (
), if logging is disabled for all signals. Click the check box to cycle through different states.
In the Contents pane table, for the signals for which you want to override logging properties, enable logging by selecting the check box in the
DataLogging
column.To enable logging for multiple signals, hold the Shift or Ctrl key and select a range of signals or individual signals. Select the check box in the
DataLogging
column of one of the highlighted signals.In the Contents pane table, modify the settings for properties, such as
DecimateData
andDecimation
.
Override Signal Logging Settings from MATLAB
You can use the MATLAB command-line interface for overriding signal logging settings.
To query a model for its signal logging override status, use the
DataLoggingOverride
model parameter.To configure signal logging from the command line, use functions and properties of the following objects:
Simulink.SimulationData.ModelLoggingInfo
— Override settings for a model. This object corresponds to the overall Signal Logging Selector interface.Simulink.SimulationData.SignalLoggingInfo
— Override settings for a specific signal. This object corresponds to a row in the logging property table in the Signal Logging Selector:Simulink.SimulationData.LoggingInfo
— Override settings for theLoggingInfo
property of aSimulink.SimulationData.SignalLoggingInfo
. This object corresponds to the editable columns in a row in the logging property table in the Signal Logging Selector.
To apply the configuration, use the
set_param
function with theDataLoggingOverride
model parameter.
You can control the kinds of systems from which to include logged signals. By default,
the Simulink.SimulationData.ModelLoggingInfo
object includes logged
signals from:
Libraries
Masked subsystems
Referenced models
Active variants
The following sections describe how to use the command-line interface to perform some common signal logging configuration tasks.
Create Model Logging Override Object with Logged Signals
You can create a model logging override object for the model sldemo_mdlref_bus
and automatically add each logged signal in the model to that object. The model sldemo_mdlref_bus
has four signals marked for logging.
mdl = 'sldemo_mdlref_bus';
open_system(mdl)
mdlInfo = Simulink.SimulationData.ModelLoggingInfo.createFromModel(mdl)
mdlInfo = ModelLoggingInfo with properties: Model: 'sldemo_mdlref_bus' LoggingMode: 'OverrideSignals' LogAsSpecifiedByModels: {} Signals: [1x4 Simulink.SimulationData.SignalLoggingInfo]
The LoggingMode
property is set to 'OverrideSignals'
, which configures the model logging override object to log only the signals specified in the Signals
property.
Apply the model override object settings. The software saves the settings when you save the model.
set_param(mdl,'DataLoggingOverride',mdlInfo);
Log Top-Level and Referenced Models as Specified in Model
You can control whether a top-level model and referenced models use override signal logging settings or use the signal logging settings specified by the model. This example shows how to log all signals as specified in the top model and all referenced models.
The model sldemo_mdlref_bus
has four signals marked for logging. For more information about the model, see Interface Specification Using Bus Objects.
mdl = "sldemo_mdlref_bus";
open_system(mdl)
Create a model logging override object.
mdlInfo = Simulink.SimulationData.ModelLoggingInfo(mdl);
To specify whether to use the signal logging settings as specified in the model and all referenced models, or to override those settings, use the LoggingMode
property of the model logging override object.
mdlInfo.LoggingMode = 'LogAllAsSpecifiedInModel'
mdlInfo = ModelLoggingInfo with properties: Model: 'sldemo_mdlref_bus' LoggingMode: 'LogAllAsSpecifiedInModel' LogAsSpecifiedByModels: {} Signals: [0x0 Simulink.SimulationData.SignalLoggingInfo]
Use the set_param
function to apply the model override object settings. The software saves the settings when you save the model.
set_param(mdl,'DataLoggingOverride',mdlInfo);
Simulate the model. The signal logging output is stored in topOut
.
sim(mdl); topOut
topOut = Simulink.SimulationData.Dataset 'topOut' with 4 elements Name BlockPath ____________ ________________________________________ 1 [1x1 Signal] COUNTERBUS sldemo_mdlref_bus/Concatenate 2 [1x1 Signal] OUTERDATA sldemo_mdlref_bus/CounterA 3 [1x1 Signal] INCREMENTBUS sldemo_mdlref_bus/IncrementBusCreator 4 [1x1 Signal] INNERDATA ...erA|sldemo_mdlref_counter_bus/COUNTER - Use braces { } to access, modify, or add elements using index.
Set Logging Mode of Model Logging Override Object
You can use the setLogAsSpecifiedInModel
function to override signal logging settings specified in a model. For example, you can log only the top model or only a referenced model in a model hierarchy. The model sldemo_mdlref_bus
contains a Model block named CounterA
that references the model sldemo_mdlref_counter_bus
. In total, four signals are marked for logging. The top model has three signals marked for logging: COUNTERBUS
, INCREMENTBUS
, and OUTERDATA
. The referenced model has one signal marked for logging: INNERDATA
.
mdl = 'sldemo_mdlref_bus'; mdlInner = 'sldemo_mdlref_bus/CounterA'; open_system(mdl)
Create an empty Simulink.SimulationData.ModelLoggingInfo
object so that no signals are logged when the logging mode is set to the override settings specified in the Signals
property.
mdlInfo = Simulink.SimulationData.ModelLoggingInfo(mdl);
You can use the setLogAsSpecifiedInModel
function to log only signals in the top model using the logging settings specified in that model. Set the outer model to log signals as specified in the model. Then, set the inner model to use override settings. Since the Signals
property vector is empty, no signals are logged when override settings are applied.
mdlInfo = setLogAsSpecifiedInModel(mdlInfo,mdl,true); mdlInfo = setLogAsSpecifiedInModel(mdlInfo,mdlInner,false);
The getLogAsSpecifiedInModel
function returns the logging mode.
outerLogMode = getLogAsSpecifiedInModel(mdlInfo,mdl)
outerLogMode = logical
1
innerLogMode = getLogAsSpecifiedInModel(mdlInfo,mdlInner)
innerLogMode = logical
0
Apply the model override object settings. Then, simulate the model. The software logs only those signals marked for logging in the top model.
set_param(mdl,'DataLoggingOverride',mdlInfo);
sim(mdl);
topOut
topOut = Simulink.SimulationData.Dataset 'topOut' with 3 elements Name BlockPath ____________ _____________________________________ 1 [1x1 Signal] COUNTERBUS sldemo_mdlref_bus/Concatenate 2 [1x1 Signal] OUTERDATA sldemo_mdlref_bus/CounterA 3 [1x1 Signal] INCREMENTBUS sldemo_mdlref_bus/IncrementBusCreator - Use braces { } to access, modify, or add elements using index.
You can also use the setLogAsSpecifiedInModel
function to log only signals in the referenced model using the logging settings specified in that model. Set the outer model to use override settings. Then, set the inner model to log signals as specified in the model.
mdlInfo = setLogAsSpecifiedInModel(mdlInfo,mdl,false); mdlInfo = setLogAsSpecifiedInModel(mdlInfo,mdlInner,true);
To verify that the logging mode for the top model and inner model have changed, you can use the getLogAsSpecifiedInModel
function .
outerLogMode = getLogAsSpecifiedInModel(mdlInfo,mdl)
outerLogMode = logical
0
innerLogMode = getLogAsSpecifiedInModel(mdlInfo,mdlInner)
innerLogMode = logical
1
Apply the model override object settings. Then, simulate the model. This time, the software logs only the INNERDATA
signal.
set_param(mdl,'DataLoggingOverride',mdlInfo);
sim(mdl);
topOut
topOut = Simulink.SimulationData.Dataset 'topOut' with 1 element Name BlockPath _________ ________________________________________ 1 [1x1 Signal] INNERDATA ...erA|sldemo_mdlref_counter_bus/COUNTER - Use braces { } to access, modify, or add elements using index.
Override Signal Logging Settings for Specific Signal
You can use Simulink.SignalData.SignalLoggingInfo
objects to programmatically override logging settings for specific signals. For example, you can create a Simulink.SimulationData.SignalLoggingInfo
object to override the signal logging settings such that only one of several signals marked for logging is logged.
This example uses a model of a rotating clutch system. In the model, ten signals are marked for logging. For more information about the model, see Building a Clutch Lock-Up Model.
mdl = "sldemo_clutch_override";
open_system(mdl);
You can use a Simulink.SimulationData.SignalLoggingInfo
object to log only the VehicleSpeed
signal. The VehicleSpeed
signal is connected the second output port of the Unlocked
subsystem. Create a Simulink.SimulationData.SignalLoggingInfo
object for the VehicleSpeed
signal by using the BlockPath
and OutputPortIndex
properties.
blkPath = "sldemo_clutch_override/Unlocked";
portNum = 2;
sigInfo = Simulink.SimulationData.SignalLoggingInfo(blkPath,portNum);
Create an empty Simulink.SimulationData.ModelLoggingInfo
object. Then, assign the signal logging override settings sigInfo
to the model logging information object.
mdlInfo = Simulink.SimulationData.ModelLoggingInfo(mdl); mdlInfo.Signals(1) = sigInfo;
Use the verifySignalAndModelPaths
function to ensure that you specified valid signal logging settings for the model.
verifiedObj = verifySignalAndModelPaths(mdlInfo)
verifiedObj = ModelLoggingInfo with properties: Model: 'sldemo_clutch_override' LoggingMode: 'OverrideSignals' LogAsSpecifiedByModels: {} Signals: [1x1 Simulink.SimulationData.SignalLoggingInfo]
Apply the model override object settings using the set_param
function.
set_param(mdl,'DataLoggingOverride',mdlInfo)
Simulate the model. Verify that VehicleSpeed
is the only signal logged by accessing the Simulink.SimulationData.Dataset
object sldemo_clutch_output
.
sim(mdl); sldemo_clutch_output
sldemo_clutch_output = Simulink.SimulationData.Dataset 'sldemo_clutch_output' with 1 element Name BlockPath ____________ _______________________________ 1 [1x1 Signal] VehicleSpeed sldemo_clutch_override/Unlocked - Use braces { } to access, modify, or add elements using index.
Log Subset of Sample Points
You can use a Simulink.SimulationData.LoggingInfo
object to create a set of signal logging override settings for a signal. For example, you can change the decimation settings to log a subset of sample points in a signal.
Open the model sldemo_mdlref_bus
. By default, the model does not decimate data. For more information about the model, see Interface Specification Using Bus Objects.
mdl = "sldemo_mdlref_bus";
open_system(mdl)
You can override signal logging settings so the software logs only a subset of sample points in the COUNTERBUS
signal by specifying a decimation factor in the LoggingInfo
property of a signal logging override object. First, create a Simulink.SimulationData.LoggingInfo
object with default settings.
logInfo = Simulink.SimulationData.LoggingInfo;
Change the DecimateData
and Decimation
properties to log every tenth data point, starting with the first sample point.
logInfo.DecimateData = true; logInfo.Decimation = 10;
Create a Simulink.SimulationData.SignalLoggingInfo
object for the COUNTERBUS
signal. Then, to log only the subset of data points in the COUNTERBUS
signal, set the LoggingInfo
property of the signal logging override object to logInfo
.
blkPath = "sldemo_mdlref_bus/Concatenate";
sigInfo = Simulink.SimulationData.SignalLoggingInfo(blkPath);
sigInfo.LoggingInfo = logInfo;
Create an empty Simulink.SimulationData.ModelLoggingInfo
object. Then, assign the signal logging override settings sigInfo
to the model logging information object.
mdlInfo = Simulink.SimulationData.ModelLoggingInfo(mdl); mdlInfo.Signals = sigInfo;
Apply the model override object settings using the set_param
function.
set_param(mdl,'DataLoggingOverride',mdlInfo)
Related Examples
- Mark Signals for Logging
- Save Signal Data Using Signal Logging
- Viewing Signals in Model Reference Instances