Main Content

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 specifiedindexin the Simulation Data Inspector repository.

Examples

collapse all

Many tasks performed using the Simulation Data Inspector programmatic interface start with obtaining the run ID for a simulation run. This example illustrates several methods to get the run ID for a run. You can use the run ID to access theSimulink.sdi.Runobject that contains the run data and metadata and perform run comparisons using theSimulink.sdi.compareRunsfunction.

Create a Run

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

load_system('sldemo_fuelsys') sim('sldemo_fuelsys')

Get Run ID UsingSimulink.sdi.getAllRunIDs

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

runIDs = Simulink.sdi.getAllRunIDs; runID = runIDs(end);

Get Run ID UsingSimulink.sdi.getRunIDByIndex

You can also use theSimulink.sdi.getRunCountandSimulink.sdi.getRunIDByIndexfunctions to get the run ID for a run. This method is useful if you also want to usecountas a counting variable to index through the runs in the Simulation Data Inspector repository.

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

Get Run ID from aSimulink.sdi.RunObject

你也可以运行从th IDeSimulink.sdi.Runobject that corresponds to the run. This example uses theSimulink.sdi.getCurrentSimulationRunfunction to get theRunobject that corresponds to the most recent simulation of thesldemo_fuelsysmodel. You can also use theSimulink.sdi.Run.getLatestfunction to access the most recently createdRunobject.

fuelsysRun = Simulink.sdi.getCurrentSimulationRun('sldemo_fuelsys'); runID = fuelsysRun.ID;

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