Simulink.sdi.getRunIDByIndex

Use Simulation Data Inspector run index to get run ID

Description

example

runID = Simulink.sdi.getRunIDByIndex(index) returns the run ID for the run with the specified index in the Simulation Data Inspector repository.

Examples

collapse all

Many workflows that use the Simulation Data Inspector programmatic interface start with obtaining the ID for a simulation run. This example shows two different methods to use the programmatic interface to get the run ID for a run. You can use the run ID to create a Simulink.sdi.Run object to access run data and metadata, or you can use the run ID for a comparison.

Simulate a Model to Create a Run

The model sldemo_fuelsys is already configured for logging. When you simulate the model, the Simulation Data Inspector automatically creates a run and assigns it a run ID.

% Load and simulate system
load_system('sldemo_fuelsys')
sim('sldemo_fuelsys')

Get Run ID Using Simulink.sdi.getAllRunIDs

Simulink.sdi.getAllRunIDs returns an array of all run IDs for runs in the Simulation Data Inspector repository in order, with the most recently created run at the end.

% Get runID for most recent run
runIDs = Simulink.sdi.getAllRunIDs;
runID = runIDs(end);

Get Run ID Using Simulink.sdi.getRunIDByIndex

You can also use Simulink.sdi.getRunCount and Simulink.sdi.getRunIDByIndex to get the run ID for a run. This method is useful if you also want to use count as a counting variable to index through the runs in the Simulation Data Inspector repository.

count = Simulink.sdi.getRunCount;
runID = Simulink.sdi.getRunIDByIndex(count);

Input Arguments

collapse all

Positive, whole number index of the run in the Simulation Data Inspector repository.

Example: 3

Output Arguments

collapse all

Numeric run identification assigned by the Simulation Data Inspector.

Introduced in R2011b