Get all Simulation Data Inspector run identifiers



runIDs = Simulink.sdi.getAllRunIDs returns a matrix of the run identifiers for all runs in the Simulation Data Inspector repository.


collapse all

Many workflows that use the Simulation Data Inspector programmatic interface start with obtaining the ID for a simulation run. This example shows two different methods to use the programmatic interface to get the run ID for a run. You can use the run ID to create a Simulink.sdi.Run object to access run data and metadata, or you can use the run ID for a comparison.

Simulate a Model to 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.

% Load and simulate system

Get Run ID Using Simulink.sdi.getAllRunIDs

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

% Get runID for most recent run
runIDs = Simulink.sdi.getAllRunIDs;
runID = runIDs(end);

Get Run ID Using Simulink.sdi.getRunIDByIndex

You can also use Simulink.sdi.getRunCount and Simulink.sdi.getRunIDByIndex to get the run ID for a run. This method is useful if you also want to use count as a counting variable to index through the runs in the Simulation Data Inspector repository.

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

You can change tolerance values on a signal-by-signal basis to evaluate the effect of a model parameter change. This example uses the slexAircraftExample model and the Simulation Data Inspector to evaluate the effect of changing the time constant for the low-pass filter following the control input.


Load the model, and mark the q, rad/sec and alpha, rad signals for logging. Then, simulate the model to create the baseline run.

% Load example model

% Mark the q, rad/sec and alpha, rad signals for logging
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Aircraft Dynamics Model',3,'on')
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Aircraft Dynamics Model',4,'on')

% Simulate system
out_1 = sim('slexAircraftExample');

Modify Model Parameter

Modify the model parameter Ts in the model workspace to change the time constant of the input low-pass filter.

% Change input filter time constant
modelWorkspace = get_param('slexAircraftExample','modelworkspace');

% Simulate again
out_2 = sim('slexAircraftExample');

Compare Runs and Inspect Results

Use the Simulink.sdi.compareRuns function to compare the data from the simulations. Then, inspect the match property of the signal result to see whether the signals fell within the default tolerance of 0.

% Get run data
runIDs = Simulink.sdi.getAllRunIDs;
runID1 = runIDs(end - 1);
runID2 = runIDs(end);

% Compare runs
diffRun1 = Simulink.sdi.compareRuns(runID1,runID2);

% Get signal result
sig1Result1 = getResultByIndex(diffRun1,1);
sig2Result1 = getResultByIndex(diffRun1,2);

% Check whether signals matched
ans = 
ans = 

Compare Runs with Signal Tolerances

The signals did not match within the default tolerance of 0. To further analyze the effect of the time constant change, add signal tolerances to the comparison with the baseline signal properties to determine the tolerance required for a pass. This example uses a combination of time and absolute tolerances.

% Get signal object for sigID1
run1 = Simulink.sdi.getRun(runID1);
sigID1 = getSignalIDByIndex(run1,1);
sigID2 = getSignalIDByIndex(run1,2);

sig1 = Simulink.sdi.getSignal(sigID1);
sig2 = Simulink.sdi.getSignal(sigID2);

% Set tolerances for q, rad/sec
sig1.AbsTol = 0.1;
sig1.TimeTol = 0.6;

% Set tolerances for alpha, rad
sig2.AbsTol = 0.2;
sig2.TimeTol = 0.8;

% Run the comparison again
diffRun2 = Simulink.sdi.compareRuns(runID1,runID2);
sig1Result2 = getResultByIndex(diffRun2,1);
sig2Result2 = getResultByIndex(diffRun2,2);

% Check the result
ans = 
ans = 

Output Arguments

collapse all

Matrix of run IDs in the Simulation Data Inspector repository.

Introduced in R2017a