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

This example shows how to modify a parameter for all the runs in the Simulation Data Inspector programmatically.

Generate Runs

Load the vdp model and mark the x1 and x2 signals for logging. Then, run several simulations.

% Clear all data from the Simulation Data Inspector repository
Simulink.sdi.clear

% Load the model and mark signals of interest for streaming
load_system('vdp')
Simulink.sdi.markSignalForStreaming('vdp/x1',1,'on')
Simulink.sdi.markSignalForStreaming('vdp/x2',1,'on')

% Simulate the model with several Mu values
for gain = 1:5
    gainVal = num2str(gain);
    set_param('vdp/Mu','Gain',gainVal)
    sim('vdp');
end

Use Simulink.sdi.getRunCount to Assign Tolerance to x1 Signals

count = Simulink.sdi.getRunCount;

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

% Open the Simulation Data Inspector to view your data
Simulink.sdi.view

Output Arguments

collapse all

Number of runs in the Simulation Data Inspector repository.

Introduced in R2011b