Main Content

Simulink.sdi.getRunCount

Get number of runs in Simulation Data Inspector repository

Description

example

count = Simulink.sdi.getRunCount returns the number of runs in the Simulation Data Inspector repository. You can use the run count to loop over all runs in the Simulation Data Inspector repository to modify run or signal properties. For example, you could add an absolute tolerance to a signal in every run.

Examples

collapse all

You can use the Simulation Data Inspector programmatic interface to modify a parameter for the same signal in multiple runs. This example adds an absolute tolerance of 0.1 to a signal in all four runs of data.

First, clear the workspace and load the Simulation Data Inspector session with the data. The session includes logged data from four simulations of a Simulink® model of a longitudinal controller for an aircraft.

Simulink.sdi.clear
Simulink.sdi.load('AircraftExample.mldatx');

Use the Simulink.sdi.getRunCount function to get the number of runs in the Simulation Data Inspector. You can use this number as the index for a for loop that operates on each run.

count = Simulink.sdi.getRunCount;

Then, use a for loop to assign the absolute tolerance of 0.1 to the first signal in each run.

for a = 1:count
    runID = Simulink.sdi.getRunIDByIndex(a);
    aircraftRun = Simulink.sdi.getRun(runID);
    sig = getSignalByIndex(aircraftRun,1);
    sig.AbsTol = 0.1;
end

Output Arguments

collapse all

Number of runs in the Simulation Data Inspector repository.

Version History

Introduced in R2011b