Contents

Simulink.sdi.addToRun

Add new simulation data to existing run

Syntax

signalIDs = Simulink.sdi.addToRun(runID,'base',{varName1,...,varNameN})
signalIDs = Simulink.sdi.addToRun(runID,'model',modelNameOrHandle)
signalIDs = Simulink.sdi.addToRun(runID,'vars',var1,...,varN)
signalIDs = Simulink.sdi.addToRun(runID,'namevalue',{Name1,...,NameN},{Value1,...,ValueN})

Description

signalIDs = Simulink.sdi.addToRun(runID,'base',{varName1,...,varNameN}) creates a run with data from the base workspace. {var1Name,...,var2Name} is a cell array of strings, which are the names of variables in the base workspace.

signalIDs = Simulink.sdi.addToRun(runID,'model',modelNameOrHandle) creates a run with the model simulation data, as specified on the Data Import/Export pane of the Configuration Parameters dialog box. modelNameOrHandle is a string, specifying the model name, or a model handle. When calling this function, the model must be open.

signalIDs = Simulink.sdi.addToRun(runID,'vars',var1,...,varN) creates a run with data stored as variables, var1,...,varN. These variables are assumed to be in the calling workspace.

signalIDs = Simulink.sdi.addToRun(runID,'namevalue',{Name1,...,NameN},{Value1,...,ValueN}) creates a run from simulation data, Value1, and provides the ability to specify a name, Name1, for the data in the run.

Input Arguments

runID

Run ID, a unique number identifying a run in the Simulation Data Inspector.

Output Arguments

signalIDs

Array of numbers where each element is a unique ID for a signal added to the run.

Examples

Add simulation data from the base workspace:

% Configure model "slexAircraftExample" for logging and simulate
simOut = sim('slexAircraftExample','SaveOutput','on','SaveFormat', ...
             'StructureWithTime','ReturnWorkspaceOutputs','on');

% Create a Simulation Data Inspector run
runID = Simulink.sdi.createRun('My Run')

% Add simulation output from the base workspace
Simulink.sdi.addToRun(runID,'base',{'simOut'});

% See the results in Simulation Data Inspector
Simulink.sdi.view;

Add simulation data as specified in a model:

sldemo_absbrake;
 
% Run simulation using the Simulink menu or the toolbar.
% Create a Data Inspector run
runID = Simulink.sdi.createRun('My Run');
Simulink.sdi.addToRun(runID, 'model', 'sldemo_absbrake');
 
% See the results in Simulation Data Inspector
Simulink.sdi.view;

Add simulation data by passing variables directly to Simulink.sdi.addToRun:

% Configure model "slexAircraftExample" for logging and simulate
simOut = sim('slexAircraftExample','SaveOutput','on','SaveFormat', ...
             'StructureWithTime','ReturnWorkspaceOutputs','on');

% Create a Simulation Data Inspector run
runID = Simulink.sdi.createRun('My Run');
Simulink.sdi.addToRun(runID,'vars',simOut);

% See the results in Simulation Data Inspector
Simulink.sdi.view;

Add simulation data and name the data:

% Configure model "slexAircraftExample" for logging and simulate
simOut = sim('slexAircraftExample','SaveOutput','on', ...
             'SaveFormat','StructureWithTime', ...
             'ReturnWorkspaceOutputs','on');

% Create a Simulation Data Inspector run
runID = Simulink.sdi.createRun('My Run');
% Name simulation output passed to Simulink.sdi.addToRun
Simulink.sdi.addToRun(runID, 'namevalue', {'MyData'}, {simOut});

% See the results in Simulation Data Inspector
Simulink.sdi.view;
Was this topic helpful?