Main Content

Simulink.SimulationData.SignalLoggingInfo

Signal logging override settings for signal

Description

Use a Simulink.SimulationData.SignalLoggingInfo object to override signal logging settings for a single logged signal without changing the model in the Simulink® Editor.

Creation

Description

sigInfo = Simulink.SimulationData.SignalLoggingInfo creates a Simulink.SimulationData.LoggingInfo object that contains default logging settings for a signal.

sigInfo = Simulink.SimulationData.SignalLoggingInfo(blkPath) specifies the BlockPath parameter and sets the output port index to 1.

example

sigInfo = Simulink.SimulationData.SignalLoggingInfo(blkPath, portIdx) specifies the OutputPortIndex parameter.

Properties

expand all

Block path of source block of the signal to log, specified as a Simulink.BlockPath object, a character vector, or a string. The block path represents the full model reference hierarchy.

For a model that uses model referencing, specify a specific instance of a signal by using an absolute path that reflects the model reference hierarchy, starting at the top model. For example:

openExample('sldemo_mdlref_basic')
sig_log_info = Simulink.SimulationData.SignalLoggingInfo(...
{'sldemo_mdlref_basic/CounterA','sldemo_mdlref_counter/Switch'})

Output port index to which the signal logging override settings apply, specified as a positive integer.

Logging override settings, specified as a Simulink.SimulationData.LoggingInfo object. The logging settings specify whether signal logging is overridden for this signal. The logging settings also can specify a logging name, a decimation factor, and a maximum number of data points.

Examples

collapse all

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.

Version History

Introduced in R2012b