runObj = Simulink.sdi.Run.getLatest returns
the most recently created run in the Simulation Data Inspector repository. A run is created
when you simulate a model that logs data or when you import data into the Simulation Data
Inspector.
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.
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.
fuelsysRun = Simulink.sdi.Run.getLatest;
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.
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.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.