Save and restore signal logging specification
Simulink.HMI.InstrumentedSignals object acts as a
specification for logged signals in a model, including signals in subsystems, library
instances, and Stateflow® charts. You can get a
object for the logging configuration in your model using the
get_param function with the
parameter. You can save several logging configurations as
Simulink.HMI.InstrumentedSignals objects and easily swap the
logging configuration for your model using
InstrumentedSignals object for a model does not include
signals logged inside referenced models. To get a list of logged signals in a
referenced model, create an
InstrumentedSignals object for the
get_param function returns a
Simulink.HMI.InstrumentedSignals object for the
InstrumentedSignals model parameter.
Model — Model name
Name of the model that corresponds to the list of logged signals.
Count — Number of logged signals
Number of logged signals in the model.
Save and Restore a Set of Logged Signals
This example shows how to use the
Simulink.HMI.InstrumentedSignals object to save a set of logged signals to restore after running a simulation with a different signal logging configuration.
Save the Initial Signal Logging Configuration
This example uses the
sldemo_fuelsys model, which is configured to log 10 signals. Open the model and use the
get_param function to get a
Simulink.HMI.InstrumentedSignals object representing the signal logging configuration.
load_system sldemo_fuelsys initSigs = get_param('sldemo_fuelsys','InstrumentedSignals');
You can save the initial signal logging configuration in a MAT-file for later use.
save initial_instSigs.mat initSigs
Remove All Logging Badges
To return to a baseline of no logged signals, you can use the
set_param function to remove all logging badges from signals in your model. Then, you can easily select a different configuration of signals to log in the Simulink™ Editor or using the
Restore Saved Logging Configuration
After working with a different set of logged signals, you can restore a saved configuration using the
Simulink.HMI.InstrumentedSignals object. For example, if you saved the logging configuration to a MAT-file, you can load the MAT-file contents into the workspace and use the
set_param function to restore the previously saved logging configuration.
load initial_instSigs.mat set_param('sldemo_fuelsys','InstrumentedSignals',initSigs)