Documentation

Simulink.sdi.createRun

Create run in Simulation Data Inspector

Syntax

  • runID = Simulink.sdi.createRun
    example
  • runID = Simulink.sdi.createRun(runName)
    example
  • runID = Simulink.sdi.createRun(runName,'base',varName)
    example
  • runID = Simulink.sdi.createRun(runName,'model',modelNameOrHandle)
    example
  • runID = Simulink.sdi.createRun(runName,'vars',var)
    example
  • runID = Simulink.sdi.createRun(runName,'namevalue',dataName,dataValue)
    example
  • runID = Simulink.sdi.createRun(runName,'file',fileName)
    example
  • [runID,runIndex] = Simulink.sdi.createRun(___)
  • [runID,runIndex,signalIDs] = Simulink.sdi.createRun(___)

Description

example

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

example

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

example

runID = Simulink.sdi.createRun(runName,'base',varName) creates a run in the Simulation Data Inspector with data, varName, from the base workspace.

example

runID = Simulink.sdi.createRun(runName,'model',modelNameOrHandle) creates a run in the Simulation Data Inspector with model simulation output data, as specified on the Data Import/Export pane of the Configuration Parameters dialog box. modelNameOrHandle is a character vector specifying the model name of a model handle. Open the model before you use this syntax.

example

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

example

runID = Simulink.sdi.createRun(runName,'namevalue',dataName,dataValue) creates a run in the Simulation Data Inspector from simulation data dataValue. dataName specifies a name for the data.

example

runID = Simulink.sdi.createRun(runName,'file',fileName) creates a run in the Simulation Data Inspector with data from a MAT-file, fileName.

[runID,runIndex] = Simulink.sdi.createRun(___) creates a run in the Simulation Data Inspector and returns the run ID and the run index. Use this option with any of the input argument combinations in the previous syntaxes.

[runID,runIndex,signalIDs] = Simulink.sdi.createRun(___) creates a run in the Simulation Data Inspector and returns the run ID, the run index, and the signal IDs. Use this option with any of the input argument combinations in the previous syntaxes.

Examples

collapse all

runID = Simulink.sdi.createRun;
runID = Simulink.sdi.createRun('My Run');
% 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;

The model must be open to use this function signature.

% Open the model sldemo_absbrake
sldemo_absbrake;

Click Run to simulate the model. 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;
% Configure the model slexAircraftExample for logging and simulate
simOut = sim('slexAircraftExample','SaveOutput','on',...
             'SaveFormat','StructureWithTime',...
             'ReturnWorkspaceOutputs','on');

% Create a Simulation Data Inspector run named 'My Run' using
% simulation output data from the model
Simulink.sdi.createRun('My Run','vars',simOut);

% Open the Simulation Data Inspector tool to view the data
Simulink.sdi.view;
% Configure the model slexAircraftExample for logging and simulate
simOut = sim('slexAircraftExample','SaveOutput','on', ...
             'SaveFormat','StructureWithTime',...
             'ReturnWorkspaceOutputs','on');

% Create a Simulation Data Inspector run named 'My Run' using
% simulation output data from the model
Simulink.sdi.createRun('My Run','namevalue',{'MyData'},{simOut});

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

This example includes data from a code generation build and requires Simulink® Coder™.

% 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.

Related Examples

Input Arguments

collapse all

Name of the run as it appears in the Simulation Data Inspector, specified as a character vector.

The names of variables in the base workspace, specified as a cell array of character vectors.

Example: {'simOut'}

The model name, or a model handle, specified as a character vector.

Example: 'sldemo_absbrake'

Data stored as variables. These variables are assumed to be in the calling workspace.

Example: simOut

Name of the data in the run, specified as a cell array.

Example: {'MyData'}

Values of the signal data, specified as a cell array.

Example: {simOut}

The file name and path of a MAT-file containing simulation data, specified as a character vector.

Example: 'slexAircraftExample.mat'

Output Arguments

collapse all

Unique number identifying a run in the Simulation Data Inspector, returned as an integer.

Number representing an index to the list of runs currently in the Simulation Data Inspector, returned as an integer.

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

More About

collapse 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.

Introduced in R2011b

Was this topic helpful?