Documentation Center

  • Trial Software
  • Product Updates

Contents

Simulink.sdi.createRun

Create run in Simulation Data Inspector

Syntax

runID = Simulink.sdi.createRun()
runID = Simulink.sdi.createRun(runName)
runID = Simulink.sdi.createRun(runName,'base',{varName1,...,varNameN})
runID = Simulink.sdi.createRun(runName,'model',modelNameOrHandle)
runID = Simulink.sdi.createRun(runName, 'vars', var1,...,varN)
runID = Simulink.sdi.createRun(runName,'namevalue',{varName1,...,varNameN},{varValue1,...,varValueN})
runID = Simulink.sdi.createRun(runName,'file',fileName)
[runID,runIndex] = Simulink.sdi.createRun(...)
[runID,runIndex,signalIDs] = Simulink.sdi.createRun(...)

Description

runID = Simulink.sdi.createRun() creates an empty unnamed run in the Simulation Data Inspector and returns the corresponding run ID.

runID = Simulink.sdi.createRun(runName) creates an empty run named runName in the Simulation Data Inspector repository and returns the corresponding run ID.

runID = Simulink.sdi.createRun(runName,'base',{varName1,...,varNameN}) creates a run with data from the base workspace. var1Name to var2Name are names of variables in the base workspace.

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

runID = Simulink.sdi.createRun(runName, 'vars', var1,...,varN) creates a run with data stored in variables, var1,...,varN. These variables must be in the calling workspace.

runID = Simulink.sdi.createRun(runName,'namevalue',{varName1,...,varNameN},{varValue1,...,varValueN}) creates a run from simulation data. varValue1 contains the data and varName1 specifies a name for the data.

runID = Simulink.sdi.createRun(runName,'file',fileName) creates a run with data extracted from a MAT-file, fileName.

[runID,runIndex] = Simulink.sdi.createRun(...) creates a run according to the input arguments specification and returns the run ID and the run index to the run currently stored in the Simulation Data Inspector.

[runID,runIndex,signalIDs] = Simulink.sdi.createRun(...) creates a run according to the input arguments specification and returns the run ID, the run index, and the signal IDs. The signal IDs are stored in a vector of numbers, where each element is a unique signal ID for each signal in the new run.

Input Arguments

runName

A string specifying a name for the run.

Output Arguments

runID

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

runIndex

Number representing an index to the list of runs currently in the Simulation Data Inspector.

signalIDs

Vector of numbers, where each element is a unique ID for a signal in a run.

Examples

expand all

Empty Run With No Name

Create an empty run in the Simulation Data Inspector.

runID = Simulink.sdi.createRun();

Empty Run With a Name

Create an empty run in the Simulation Data Inspector and give it a name.

runID = Simulink.sdi.createRun('My Run');

Simulation Output Data in the Base Workspace

Create a run in the Simulation Data Inspector from output data in the base workspace.

Configure the model, slexAircraftExample, for logging and simulate.

simOut = sim('slexAircraftExample','SaveOutput','on',...
             'SaveFormat','StructureWithTime',...
             'ReturnWorkspaceOutputs','on');

Create a Simulation Data Inspector run from the simulation output data in the base workspace.

Simulink.sdi.createRun('My Run','base',{'simOut'});

Open the Simulation Data Inspector tool to view the data.

Simulink.sdi.view;

Simulation Output Data for a Model

Create a run from simulation output data as specified in the model. The model must be open to use this function signature.

Open the model sldemo_absbrake.

sldemo_absbrake;

Run the simulation using the model diagram menu or the toolbar. The model is already configured for signal logging.

Create a Simulation Data Inspector run named, My Run, using simulation output data from the model.

Simulink.sdi.createRun('My Run','model','sldemo_absbrake');

Open the Simulation Data Inspector tool to view the data.

Simulink.sdi.view;

A run named, My Run, appears in the Simulation Data Inspector.

Passed Variables

Create a run in the Simulation Data Inspector by directly passing data through variables.

Configure model slexAircraftExample for logging and simulate.

simOut = sim('slexAircraftExample','SaveOutput','on', ...
             'SaveFormat','StructureWithTime', ...
             'ReturnWorkspaceOutputs','on');   

Create a Simulation Data Inspector run named, My Run, by passing the simulation output variable, simOut.

Simulink.sdi.createRun('My Run','vars',simOut);    

Open the Simulation Data Inspector tool to view the data.

Simulink.sdi.view;

A run named, My Run, appears in the Simulation Data Inspector.

Include Name of Simulation Data in the Run

Create a Simulation Data Inspector run and provide a name for the passed data.

Configure model slexAircraftExample for logging and simulate.

simOut = sim('slexAircraftExample','SaveOutput','on', ...
             'SaveFormat','StructureWithTime', ...
             'ReturnWorkspaceOutputs','on');   

Create a Simulation Data Inspector run named, My Run, by passing the simulation output variable, simOut and a name for the data, MyData.

Simulink.sdi.createRun('My Run', 'namevalue', {'MyData'}, {simOut});

Open the Simulation Data Inspector tool to view the data.

Simulink.sdi.view;

A run named, My Run, appears in the Simulation Data Inspector.

Logged MAT-file of a Code Generation Build (Requires Simulink Coder)

Create a run in the Simulation Data Inspector from data in a MAT-file, which includes data from a code generation build.

Load the model slexAircraftExample.

load_system('slexAircraftExample');

Configure the model for logging and simulate.

set_param('slexAircraftExample','SolverType','Fixed-Step',...
          'SaveOutput','on',...
          'SaveFormat','StructureWithTime', ...
          'ReturnWorkspaceOutputs','on');

Build the model to a temporary directory.

cd(tempdir);
rtwbuild('slexAircraftExample');

Run the executable.

if ispc
   system('slexAircraftExample');
elseif unix
   system('./slexAircraftExample');
end

A MAT-file is generated in the current directory.

Create a Simulation Data Inspector run using the data in the MAT-file.

Simulink.sdi.createRun('My Run','file','slexAircraftExample.mat');

Open the Simulation Data Inspector tool to view the data.

Simulink.sdi.view;

A run named, My Run, appears in the Simulation Data Inspector.

More About

expand all

Tips

  • Before calling Simulink.sdi.createRun with either ‘base' or ‘model' as an input argument, you must configure the model for logging and simulate the model.

  • When you create and add a run, the Simulation Data Inspector maintains a list of these runs. The first run in the list is given a runIndex of 1. If you delete a run from the Simulation Data Inspector, the subsequent runs move up the list and each runIndex changes. However, the run IDs remain the same.

See Also

| |

Was this topic helpful?