Simulink.HMI.InstrumentedSignals class

Package: Simulink.HMI

Access logged signals in model


Simulink.HMI.InstrumentedSignals objects contain a list of all logged signals in a model, including signals from all subsystems, library instances, and Stateflow® charts. The list does not include signals inside reference models. You can access the list of logged signals in a reference model by creating a Simulink.HMI.InstrumentedSignals object for the reference model.

The Simulink.HMI.InstrumentedSignals object provides access to Simulink.HMI.SignalSpecification objects using the get method.


instSigs = get_param(model, 'InstrumentedSignals') returns instSigs, a Simulink.HMI.InstrumentedSignals object containing a list of all of the logged signals in the model, model.

Input Arguments

expand all

Model name or full path to model.

Example: 'sldemo_fuelsys'

Example: fullpath(matlabroot, 'examples', 'simulink', 'ex_sldemo_absbrake.slx')

Desired return from get_param, specified as a character vector. Using a value of 'InstrumentedSignals', get_param returns a Simulink.HMI.InstrumentedSignals object with a list of all the logged signals.

Example: 'InstrumentedSignals'


expand all

Name of the model the aggregation of logged signals corresponds to.

Example: 'sldemo_fuelsys'

Number of logged signals in the model.

Example: 10

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects (MATLAB).


expand all

This example shows how to obtain the block paths for logged signals and remove the logging badge for a signal using Simulink.HMI.InstrumentedSignals and Simulink.HMI.SignalSpecification objects.

Get InstrumentedSignals Object

% Load the model sldemo_absbrake

% Get logged signals with Simulink.HMI.InstrumentedSignals object
instSigs = get_param('sldemo_absbrake', 'InstrumentedSignals');

% Check logged signals count
ans =



Inspect Block Paths with SignalSpecifications Objects

Use the get method to get the Simulink.HMI.SignalSpecification objects for each of the signals in the Simulink.HMI.InstrumentedSignals object

% Get Simulink.HMI.SignalSpecification objects
sig1 = instSigs.get(1);
sig2 = instSigs.get(2);

% Inspect block paths for signals
blockPath1 = sig1.BlockPath
blockPath2 = sig2.BlockPath
blockPath1 = 

  Package: Simulink

  Block Path:
    'sldemo_absbrake/Bus Creator'

  Use the getBlock method to access block path character vectors from this object.

blockPath2 = 

  Package: Simulink

  Block Path:
    'sldemo_absbrake/Relative Slip'

  Use the getBlock method to access block path character vectors from this object.

Remove Logging Badge for Bus Signal

Remove the logging badge for the signal from the Bus Creator block.

% Get block path string and port index for the Bus Creator signal
blockPath_str = blockPath1.getBlock(1);
portIndex = sig1.OutputPortIndex;

% Clear the logging badge for the Bus Creator signal
Simulink.sdi.markSignalForStreaming(blockPath_str, portIndex, 'off')

This example shows the capability of using the Simulink.HMI.InstrumentedSignals object to save a set of logged signals to restore after running a simulation with a different set of signals.

Load Model and Save Initial Configuration

Load the sldemo_fuelsys model, and save the initial set of logged signals.

% Load model
load_system sldemo_fuelsys

% Get Simulink.HMI.InstrumentedSignals object
initSigs = get_param('sldemo_fuelsys', 'InstrumentedSignals');

% Save logging configuration to file for future use
save initial_instSigs.mat initSigs

Remove All Logging Badges

Return to a baseline of no logged signals so you can easily select a different configuration of signals to log.

% Clear all logging signals
set_param('sldemo_fuelsys', 'InstrumentedSignals', [])

Restore Saved Logging Configuration

After working with a different set of logged signals, you can easily restore a saved configuration with the Simulink.HMI.InstrumentedSignals object.

% Load the saved configuration
load initial_instSigs.mat

% Restore logging configuration
set_param('sldemo_fuelsys', 'InstrumentedSignals', initSigs)

Introduced in R2015b

Was this topic helpful?