Documentation Center

  • Trial Software
  • Product Updates

Contents

Simulink.sdi.getSource

Return location for storing simulation data

Syntax

source = Simulink.sdi.getSource()

Description

source = Simulink.sdi.getSource() return the location of the Simulation Data Inspector repository for storing simulation data. Call this function before running multiple simulations in a parfor loop.

Output Arguments

source

Location of the Simulation Data Inspector repository.

Examples

expand all

Record Data During Parallel Simulations

This example shows how to run multiple simulations in a parfor loop and record each run in the Simulation Data Inspector tool.

Open the Simulation Data Inspector.

Simulink.sdi.view;

Load the model.

mdl = 'slexAircraftExample';
load_system(mdl);

Get the location of the simulation data repository.

src = Simulink.sdi.getSource();

Start a parallel pool with 4 workers.

parpool(4);

Run the simulation in a parfor loop.

parfor i=1:4
   % Set the location of the simulation data repository of this 
   % worker to be the same for aggregating the data
   Simulink.sdi.setSource(src);
   % Run the simulation
   simOut = sim(mdl,'SaveOutput','on',...
                'SaveFormat','StructureWithTime',...
                'ReturnWorkspaceOutputs','on');
   % Create a simulation run in the Simulation Data Inspector
   Simulink.sdi.createRun(['Run' num2str(i)],'namevalue',...
                          {'simout'},{simOut});
end

Delete the current parallel pool and close all of the models.

parpool close;
bdclose all;

Refresh the Simulation Data Inspector.

Simulink.sdi.refresh();

See Also

|

Was this topic helpful?