Documentation

getSignalIDByIndex

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

Return signal ID at array index

Syntax

signalID = runObj.getSignalIDByIndex(index)

Description

signalID = runObj.getSignalIDByIndex(index) returns the signal ID for the signal at the specified index to the array of signals contained in the Simulink.sdi.Run object, runObj.

Input Arguments

expand all

index — Signal array indexinteger

Index to the array of signals contained in a Simulink.sdi.Run object, specified as an integer. The first index in the array is 1.

Output Arguments

expand all

signalID — Signal identifierinteger

Unique number identifying a signal in a run, returned as an integer.

Examples

expand all

Get the Signal ID in a Run

The Simulink.sdi.Run method, getSignalIDByIndex, returns the signal ID corresponding to a signal in a run. With the signal ID you can get the signal object representing the signal data and metadata. You can compare two signals by passing their signal IDs to Simulink.sdi.compareSignals.

% 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','base',{'simOut'});
 
% Get the Simulink.sdi.Run object corresponding to the new run ID
runObj = Simulink.sdi.getRun(runID);
 
% Get the number of signals in the run
numSignals = runObj.signalCount;
 
% Get the signal ID for the first signal in the run
if numSignals > 0
   signalID = runObj.getSignalIDByIndex(1);
end

Related Examples

Introduced in R2012b

Was this topic helpful?