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.

Override signal logging properties to reduce memory overhead and to facilitate the analysis of simulation logging results. 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 class 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:   Simulink rebuilds a model in the following situation:

    1. The model contains one or more signals marked for signal logging.

    2. You simulate the model in Rapid Accelerator mode.

    3. You use the Signal Logging Selector or MATLAB® command line to modify the signal logging configuration.

    4. You simulate the model in Rapid Accelerator mode again.

Override Signal Logging Settings with the Signal Logging Selector

  1. Open the Signal Logging Selector, using one of the following approaches:

    • In the Configuration Parameters > Data Import/Export pane, in the Signals area, select the Configure Signals to Log button.

      If necessary, select Signal logging to enable the Configure Signals to Log button.

    • For a model that includes a Model block, you can also use the following approach:

      1. In the Simulink Editor, right-click a Model block.

      2. In the context-menu, select Log Referenced Signals.

  2. 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.

  3. 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 Use Signal Logging Selector to View Signal Logging Configuration.

  4. Override signal logging settings. Use one of the following approaches, depending on whether or not 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.

  1. Open the Signal Logging Selector. In the Configuration Parameters > Data Import/Export pane, in the Signals area, select the Configure Signals to Log button.

    • If necessary, select Signal logging to enable the Configure Signals to Log button.

  2. Set Logging Mode to Override signals.

  3. 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 Use Signal Logging Selector to View Signal Logging Configuration.

  4. In the Contents pane table, select the signal whose logging settings you want to override.

  5. 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 the one or more of the following 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 either solid ( ), if logging is disabled for some of signals, or empty ( ), if logging is disabled for all of the signals.

To enable logging of all logged signals for a node:

  1. Open the Signal Logging Selector. In the Configuration Parameters > Data Import/Export pane, in the Signals area, select the Configure Signals to Log button.

  2. Set Logging Mode to Override signals.

  3. 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 Use Signal Logging Selector to View Signal Logging Configuration.

  4. 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 Logged Signals in a Model 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 either solid ( ), if logging is enabled for some signals, or checked ( ), if logging is enabled for all signals.

To disable logging for all logged signals in a node of a model:

  1. Open the Signal Logging Selector. In the Configuration Parameters > Data Import/Export pane, in the Signals area, select the Configure Signals to Log button.

  2. Set Logging Mode to Override signals.

  3. 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 Use Signal Logging Selector to View Signal Logging Configuration.

  4. 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 reference model.

Override Signal Logging for a Subset of Signals.  To log some, but not all, logged signals in a model node:

  1. Open the Signal Logging Selector. In the Configuration Parameters > Data Import/Export pane, in the Signals area, select the Configure Signals to Log button.

  2. Set Logging Mode to Override signals.

  3. 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 Use Signal Logging Selector to View Signal Logging Configuration.

  4. 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.

  5. 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.

    Note:   You cannot use the Signal Logging Selector to override a subset of signals for model reference variant systems, including:

    • Model reference variants

    • Model blocks that contain a Subsystem Variant or model reference variant

    You can override programmatically a subset of signals in those configurations. For details, see Override Signal Logging Settings from MATLAB.

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.

  1. Open the Signal Logging Selector. In the Configuration Parameters > Data Import/Export pane, in the Signals area, select the Configure Signals to Log button.

  2. Set Logging Mode to Override signals.

  3. 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 Use Signal Logging Selector to View Signal Logging Configuration.

  4. 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.

  5. 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.

  6. In the Contents pane table, modify the settings for properties, such as DecimateData and Decimation.

Override Signal Logging Settings from MATLAB

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:

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.

Create a Model Logging Information Object

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_mdlref_counter_bus')));
open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ...
'examples', 'ex_bus_logging')));
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.

Specify Which Models to Log

Use the LoggingMode property of a Simulink.SimulationData.ModelLoggingInfo object to specify whether to use the signal logging settings as specified in the model and all referenced models, or to override those settings.

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, as described in the Simulink.SimulationData.ModelLoggingInfo documentation.

The following 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_mdlref_counter_bus')));
open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ...
'examples', 'ex_bus_logging')));
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_mdlref_counter_bus')));
open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ...
'examples', 'ex_bus_logging')));
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.

Log a Subset of Signals

For a simple model with a limited number of logged signals, you could create an empty Simulink.SimulationData.ModelDataLogInfo object. Then create Simulink.SimulationData.SignalLoggingInfo 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_mdlref_counter_bus')));
open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ...
'examples', 'ex_bus_logging')));
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_mdlref_counter_bus')));
open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ...
'examples', 'ex_bus_logging')));

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.

    Note:   You can override programmatically a subset of signals for model reference variant systems, including:

    • Model reference variants

    • Model blocks that contain a Subsystem Variant or model reference variant

    To log a subset of signals for these model reference variant systems, set the SignalLoggingSaveFormat parameter to Dataset.

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.

Use Simulink.SimulationData.LoggingInfo properties to override signal logging properties. The following example shows how to set the decimation override settings.

open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ...
'examples', 'ex_mdlref_counter_bus')));
open_system(docpath(fullfile(docroot, 'toolbox', 'simulink', ...
 'examples', 'ex_bus_logging')));
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.

Was this topic helpful?