Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Contents

Simulink.sdi.setSource

Set location for storing simulation data

Syntax

Simulink.sdi.setSource(source)

Description

Simulink.sdi.setSource(source) sets the location of the Simulation Data Inspector repository for storing simulation data. Before calling this function, call Simulink.sdi.getSource to get the location. Call this function in a parfor loop for recording multiple simulations in the Simulation Data Inspector repository.

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?