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 Simulink.sdi.getRun
function.
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.
Get Run Object Using Simulink.sdi.Run.getLatest
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 Simulink.sdi.Run.getLatest
function.
Get Run Object Using Simulink.sdi.getCurrentSimulationRun
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 sldemo_fuelsys
model.
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.