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.
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.
Create an empty Simulink.SimulationData.ModelLoggingInfo
object. Then, assign the signal logging override settings sigInfo
to the model logging information object.
Use the verifySignalAndModelPaths
function to ensure that you specified valid signal logging settings for the model.
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.
Simulate the model. Verify that VehicleSpeed
is the only signal logged by accessing the Simulink.SimulationData.Dataset
object 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.