Get the most recently created Simulation Data Inspector run
Access Simulation Data Inspector Runs
Many tasks performed using the Simulation Data Inspector programmatic interface start by accessing the
Simulink.sdi.Run object that corresponds to the logged or imported data you want to analyze. For example, you can use the
Run object to access the
Simulink.sdi.Signal objects that correspond to individual signals in the run.
This example shows how to access
Run objects by using the
Simulink.sdi.Run.getLatest function, the
Simulink.sdi.getCurrentSimulationRun function, or the
Create a Run
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.
Get Run Object Using
In this example, the run created when you simulated the model is the most recently created run in the Simulation Data Inspector. When you want to access the most recently created run, use the
fuelsysRun = Simulink.sdi.Run.getLatest;
Get Run Object Using
The run you want to access may not be the most recently created run in the Simulation Data Inspector. If the run corresponds to the most recent simulation of a model, you can use the
Simulink.sdi.getCurrentSimulationRun function to access the
Run object. You can also use the
Simulink.sdi.getCurrentSimulationRun function to access data for an in-progress simulation when the simulation streams data to the Simulation Data Inspector. This function can be useful when you are working with multiple models.
In this example, the run created when you simulated the model is the current simulation run for the
fuelsysRun = Simulink.sdi.getCurrentSimulationRun('sldemo_fuelsys');
Get Run Object from a Run ID
When your task also requires the run ID, you can use the
Simulink.sdi.getRun function to get the corresponding
Simulink.sdi.Run object that contains the run data and metadata.
runIDs = Simulink.sdi.getAllRunIDs; runID = runIDs(end); fuelsysRun = Simulink.sdi.getRun(runID);
runObj — Simulink.sdi.Run object
Simulink.sdi.Run object for the most
recently created run in the Simulation Data Inspector.
Introduced in R2020a