Documentation

getSignalByIndex

Class: Simulink.sdi.Run
Package: Simulink.sdi

Get Simulink.sdi.Signal object by index

Syntax

signal = runObj.getSignalByIndex(index)

Description

signal = runObj.getSignalByIndex(index) returns a signal object for the signal at the specified index within the Simulink.sdi.Run object, runObj.

Input Arguments

expand all

Index of the signal within the run.

Output Arguments

expand all

Simulink.sdi.Signal object for the signal at the specified index in the run.

Examples

expand all

This example demonstrates how to access the Simulink.sdi.Run object for a run created by logging signals to the Simulation Data Inspector. From the Simulink.sdi.Run object you can get Simulink.sdi.Signal objects that you can use to view data.

% Simulate model sldemo_absbrake to create a run
sim('sldemo_fuelsys')

% Get runID for the run
runIDs = Simulink.sdi.getAllRunIDs;
runID = runIDs(end);

% Get run object for the run
run = Simulink.sdi.getRun(runID);

% Check signal count of the run
run.signalCount
ans =

  int32

   10

% Get signal objects for the signals in the run
signal1 = run.getSignalByIndex(4);
signal2 = run.getSignalByIndex(9);
signal3 = run.getSignalByIndex(10);

% Create sub-plot layout to display signals
Simulink.sdi.setSubPlotLayout(3, 1)

% Plot signals
signal1.checked = true;
signal2.plotOnSubPlot(2, 1, true);
signal3.plotOnSubPlot(3, 1, true);

%View plots in the Simulation Data Inspector
Simulink.sdi.view

Alternatives

You can access signal properties, view signals, and export data to the workspace using the Simulation Data Inspector UI. For more information, see Organize Your Simulation Data Inspector Workspace.

Introduced in R2012b

Was this topic helpful?