Override Signal Logging Settings - MATLAB & Simulink (original) (raw)

You can use signal logging to capture signal data from a simulation without adding blocks to your model. For more information, see Save Signal Data Using Signal Logging.

As you develop a model, you may want to override the signal logging settings for a specific simulation run. You can use the Signal Logging Selector or a programmatic interface to override signal logging properties without changing the model in the Simulink® Editor. By overriding signal logging settings, you can avoid recompiling a model and reduce memory overhead.

To override signal logging settings, you can use one or a combination of these two methods:

Benefits of Overriding Signal Logging Settings

Overriding signal logging properties is useful when you want to:

Scope of Signal Logging Setting Overrides

When you override signal logging settings, the software saves the specified configuration in the model and uses those override settings when you simulate the model. However, the software does not change the signal logging settings in the Signal Properties dialog box for each signal in the model.

If you close and reopen the model, the signal logging overrides that you made are in effect if the 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

When you have a model with signals marked for signal logging that has been simulated in rapid accelerator mode, the software rebuilds the model if you override the signal logging settings and simulate the model in rapid accelerator mode again.

Override Signal Logging Settings with Signal Logging Selector

You can use the Signal Logging Selector to interactively view and override signal logging settings.

  1. Open the Signal Logging Selector. On the Modeling tab, click Model Settings to open the Configuration Parameters dialog box. Then, in the Data Import/Export pane, click Configure Signals to Log.
    The Configure Signals to Log button in the Configuration Parameters dialog box.
    Tip
    To enable the Configure Signals to Log button, select the Signal logging configuration parameter.
  2. Set Logging Mode to Override signals.
    In the Signal Logging Selector, if you override some signal logging settings and then setLogging 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.
    The Signal Logging Selector with the Logging Mode list expanded to show the Override signals option.
    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. 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 View Logging Configuration Using the Signal Logging Selector.
  4. Override signal logging settings.
    When a model includes referenced models, the check box in the Model Hierarchy pane indicates the override configuration for the model corresponding to the node.
    Check Box Signal Logging Configuration
    Filled box with white check mark For the top-level model node, logs all logged signals in the top model.For a Modelblock node, logs all logged signals in the model reference hierarchy for that block.
    Empty box For the top-level model node, disables logging for all logged signals in the top-level model.For aModel block node, disables logging for all signals in the model reference hierarchy for that block.
    Filled box with white dash For the top-level model node, logs all logged signals that have the DataLogging setting enabled.For a Model block node, logs all logged signals in the model reference hierarchy for that block that have the DataLogging setting enabled.

To apply override settings using the Signal Logging Selector, Logging Mode must be set to Override signals. If you set the Logging Mode to Log all signals as specified in model after overriding signal logging settings, the override settings are ignored and the logging settings defined in the model appear in the Signal Logging Selector. 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.

For an example of how to use the Signal Logging Selector to override the signal logging settings, see Override Signal Logging Settings.

Override Signal Logging Settings Programmatically

You can override signal logging settings programmatically using the MATLAB® command line.

To configure signal logging override settings programmatically, use functions and properties of the following objects:

To query a model for its signal logging override status, use the DataLoggingOverride model parameter.

get_param(mdl,"DataLoggingOverride")

To apply a signal logging override configuration, use the set_param function with the DataLoggingOverride model parameter.

set_param(mdl,"DataLoggingOverride",mdlInfoObject)

You can control the kinds of systems from which to include logged signals. By default, the Simulink.SimulationData.ModelLoggingInfo object includes logged signals from:

These sections describe how to perform some common signal logging configuration tasks programmatically.

For additional examples, see:

Create Model Logging Override Object with Logged Signals

You can create a model logging override object for a model and automatically add each logged signal in the model to that object.

Open the IterativeCounter project. The project opens the CounterSystem model at startup. The CounterSystem model has four signals marked for logging.

openProject("IterativeCounter"); mdl = "CounterSystem"; mdlInfo = Simulink.SimulationData.ModelLoggingInfo.createFromModel(mdl)

mdlInfo = ModelLoggingInfo with properties:

                 Model: 'CounterSystem'
           LoggingMode: 'OverrideSignals'
LogAsSpecifiedByModels: {}
               Signals: [1×4 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);

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.

Open the IterativeCounter project. The project opens the CounterSystem model at startup. This model contains a Model block that references the CounterAlgorithm model. In total, four signals are marked for logging. The top model has three signals marked for logging: BatchData, Controls, and OuterCount. The referenced model has one signal marked for logging: InnerCount.

openProject("IterativeCounter"); mdl = 'CounterSystem'; mdlInner = 'CounterSystem/Model';

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)

innerLogMode = getLogAsSpecifiedInModel(mdlInfo,mdlInner)

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); out1 = sim(mdl); out1.logsout

ans = Simulink.SimulationData.Dataset 'logsout' with 3 elements

                     Name        BlockPath                 
                     __________  _________________________ 
1  [1x1 Signal]      BatchData   CounterSystem/Concatenate
2  [1x1 Signal]      OuterCount  CounterSystem/Model      
3  [1x1 Signal]      Controls    CounterSystem/Subsystem  

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)

innerLogMode = getLogAsSpecifiedInModel(mdlInfo,mdlInner)

Apply the model override object settings. Then, simulate the model. This time, the software logs only the InnerCount signal.

set_param(mdl,DataLoggingOverride=mdlInfo); out2 = sim(mdl); out2.logsout

ans = Simulink.SimulationData.Dataset 'logsout' with 1 element

                     Name        BlockPath                                
                     __________  ________________________________________ 
1  [1x1 Signal]      InnerCount  ...l|CounterAlgorithm/For Each Subsystem

See Also

Objects

Tools

Topics