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.
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
class has a
LoggingMode
property, which corresponds to the Logging
Mode parameter in the Signal Logging Selector.
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
Simulink 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.
Open the Signal Logging Selector, using one of the following approaches:
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.
For a model that includes a Model block, you can also use the following approach:
In the Simulink Editor, right-click a Model block.
In the context menu, select Log Referenced Signals.
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.
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.
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
and
Decimation
.
The MATLAB command-line interface for overriding signal logging settings includes:
The DataLoggingOverride
model parameter — Use to view or
set signal logging override values for a model
The following classes:
—
Specify signal logging override settings for a model. This class corresponds to
the overall Signal Logging Selector interface.Simulink.SimulationData.ModelLoggingInfo
—
Override settings for a specific signal. This class corresponds to a row in the
logging property table in the Signal Logging Selector:Simulink.SimulationData.SignalLoggingInfo
— Overrides
for signal logging settings such as decimation. This class corresponds to the
editable columns in a row in the logging property table in the Signal Logging
Selector.Simulink.SimulationData.LoggingInfo
To query a model for its signal logging override status, use the
DataLoggingOverride
parameter.
To configure signal logging from the command line, use methods and properties of the
three classes listed above. To apply the configuration, use set_param
with the DataLoggingOverride
model parameter.
The following sections describe how to use the command-line interface to perform some common signal logging configuration tasks.
To use the command-line interface for overriding signal logging settings, first create
a Simulink.SimulationData.ModelLoggingInfo
object. For example, use the
following commands to create the model logging override object for the
ex_bus_logging
model and automatically add each logged signal in the
model to that object:
open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ... 'examples', 'ex_bus_logging'))); open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ... 'examples', 'ex_mdlref_counter_bus'))); mi = Simulink.SimulationData.ModelLoggingInfo.createFromModel(... 'ex_bus_logging')
mi = ModelLoggingInfo with properties: Model: 'ex_bus_logging' 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.
To apply the model override object settings, use:
set_param(ex_bus_logging, 'DataLoggingOverride', mi);
Simulink saves the settings when you save the model.
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
As an alternative, you can use the
Simulink.SimulationData.ModelLoggingInfo
constructor and specify a
Simulink.SimulationData.SignalLoggingInfo
object for each signal. To
ensure that you specified valid signal logging settings for a model, use the
verifySignalAndModelPaths
method with the
Simulink.SimulationData.ModelLoggingInfo
object for the model.
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 a
Simulink.SimulationData.ModelLoggingInfo
object.
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. See the
documentation.Simulink.SimulationData.ModelLoggingInfo
This example shows how to log all signals as specified in the top model and all
referenced models. The signal logging output is stored in
topOut
.
open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ... 'examples', 'ex_bus_logging'))); open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ... 'examples', 'ex_mdlref_counter_bus'))); mi = Simulink.SimulationData.ModelLoggingInfo... ('ex_bus_logging'); mi.LoggingMode = 'LogAllAsSpecifiedInModel'
mi = ModelLoggingInfo with properties: Model: 'ex_bus_logging' LoggingMode: 'LogAllAsSpecifiedInModel' LogAsSpecifiedByModels: {} Signals: []
To apply the model override object settings, use:
set_param(ex_bus_logging, 'DataLoggingOverride', mi);
The following example shows how to log only signals in the top model:
open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ... 'examples', 'ex_bus_logging'))); open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ... 'examples', 'ex_mdlref_counter_bus'))); mi = Simulink.SimulationData.ModelLoggingInfo... ('ex_bus_logging'); mi.LoggingMode = 'OverrideSignals'; mi = mi.setLogAsSpecifiedInModel('ex_bus_logging',true);
To apply the model override object settings, use:
set_param(ex_bus_logging,'DataLoggingOverride', mi);
Simulink saves the settings when you save the model.
For a simple model with a limited number of logged signals, you could create an empty
Simulink.SimulationData.ModelDataLogInfo
object. Then create
Simulink.SimulationData.SignalLoggingInf
o objects for each of the
signals that you want to log, and assign those objects to the model logging information
object.
open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ... 'examples', 'ex_bus_logging'))); open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ... 'examples', 'ex_mdlref_counter_bus'))); mdl = 'ex_bus_logging'; blk = 'ex_bus_logging/IncrementBusCreator'; blkPort = 1; load_system(mdl); ov = Simulink.SimulationData.ModelLoggingInfo(mdl); so = Simulink.SimulationData.SignalLoggingInfo(blk,blkPort); ov.Signals(1) = so; % apply this object so the model set_param(mdl,'DataLoggingOverride',ov); % Simulate sim(mdl); % observe that only the signal topOut
To apply the model override object settings, use:
set_param(mdl, 'DataLoggingOverride', ov);
Simulink saves the settings when you save the model.
For a model that uses model referencing, or that is complex, to specify a subset of
logged signals to log, consider using the findSignal
method with a
Simulink.SimulationData.ModelLoggingInfo
object. For example, to log
only one signal from the referenced model instance referenced by:
open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ... 'examples', 'ex_bus_logging'))); open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ... 'examples', 'ex_mdlref_counter_bus'))); mi = Simulink.SimulationData.ModelLoggingInfo.createFromModel(... 'ex_bus_logging'); pos = mi.findSignal({'ex_bus_logging/CounterA' ... 'ex_mdlref_counter_bus/Bus Creator'}, 1)
pos = 4
for idx=1:length(mi.Signals) mi.Signals(idx).LoggingInfo.DataLogging = (idx == pos); end
To apply the model override object settings, use:
set_param(ex_bus_logging,'DataLoggingOverride', mi);
Simulink saves the settings when you save the model.
In addition to overriding the setting for the DataLogging
property
for a signal, you can override other signal logging properties, such as decimation.
Use
properties to override signal
logging properties. The following example shows how to set the decimation override
settings.Simulink.SimulationData.LoggingInfo
open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ... 'examples', 'ex_bus_logging'))); open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ... 'examples', 'ex_mdlref_counter_bus'))); mi = Simulink.SimulationData.ModelLoggingInfo.createFromModel... ('ex_bus_logging'); pos = mi.findSignal({'ex_bus_logging/CounterA' ... 'ex_mdlref_counter_bus/Bus Creator'}, 1); mi.Signals(pos).LoggingInfo.DecimateData = true; mi.Signals(pos).LoggingInfo.Decimation = 2;
To apply the model override object settings, use:
set_param(ex_bus_logging,'DataLoggingOverride', mi);
Simulink saves the settings when you save the model.