Main Content

getAllSignalIDs

R2026b

Get all signal IDs for signals in Simulink.sdi.Run object

Description

sigIDs = getAllSignalIDs(runObj) returns an array, sigIDs, that contains the signal IDs for all signals in the Simulink.sdi.Run object runObj. Use the getAllSignalIDs function when you need to work with many or all of the signals in the run. When you only need to analyze a specific signal, you can access the single Signal object using the getSignalIDsByName function or the getSignalIDByIndex function.

example

Examples

collapse all

You can use the getAllSignalIDs function to access an array containing the signal IDs for all the signals in a run. This example simulates the ex_pulse_counter model to create run data and then shows how to get the signal IDs for the signals in the run and use the IDs to compare the signals.

Create a Run

This example creates a run in the Simulation Data Inspector by simulating a model that logs data. Load the ex_pulse_counter model and mark the input signal from the Pulse Generator block and the OUT bus signal from the Bus Counter subsystem for logging.

load_system('ex_pulse_counter')
Simulink.sdi.markSignalForStreaming('ex_pulse_counter/Pulse Generator',1,'on')
Simulink.sdi.markSignalForStreaming('ex_pulse_counter/Bus Counter',1,'on')

Simulate the model.

out = sim('ex_pulse_counter');

Access Run Data and Signal IDs

Use the Simulink.sdi.getCurrentSimulationRun function to access the run created when you simulated the ex_pulse_counter model.

countRun = Simulink.sdi.getCurrentSimulationRun('ex_pulse_counter');

Get an array of the signal IDs for the logged signals using the getAllSignalIDs function.

sigIDs = getAllSignalIDs(countRun);

Compare Logged Signals

You can use the signal IDs to compare the logged signals. Use the Simulink.sdi.getSignal function to get the Simulink.sdi.Signal object with the first ID in the array sigIDs. Check the Name property for the returned Signal object.

sigID1 = sigIDs(1);
sig1 = Simulink.sdi.getSignal(sigID1);
sig1.Name
ans = 
'OUT.output'

Compare the first signal with the second signal. The first signal, from the Bus Counter subsystem output, represents the counter value. The second signal, input, from the Pulse Generator block, represents the pulse input to the counter.

sigID2 = sigIDs(2);
DSR = Simulink.sdi.compareSignals(sigID1,sigID2);
DSR.Status
ans = 
  ComparisonSignalStatus enumeration

    OutOfTolerance

The signals do not match. You can use the tolerance properties of the Signal objects to programmatically analyze the data, or you can open the Simulation Data Inspector using the Simulink.sdi.view function to view and analyze the comparison results using the UI.

Clean Up

Close the model without saving to avoid modifying the example model file.

close_system('ex_pulse_counter',0)

Input Arguments

collapse all

Run containing the signals you want to access, specified as a Simulink.sdi.Run object.

Output Arguments

collapse all

Signal IDs for the signals in the run, returned as an array.

Version History

Introduced in R2020a