Documentation

getSignalIDByIndex

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

Return signal ID for signal at index

Syntax

signalID = runObj.getSignalIDByIndex(index)

Description

signalID = runObj.getSignalIDByIndex(index) returns the signal ID for the signal at the specified index in the Simulink.sdi.Run object. You can use the signal ID to create a Simulink.sdi.Signal object or to perform a signal comparison with Simulink.sdi.compareSignals.

Input Arguments

expand all

Index of the signal within the run.

Output Arguments

expand all

Unique numeric signal identifier.

Examples

expand all

This example uses the slexAircraftExample model to demonstrate the comparison of a control system's input and output signals. The example marks the signals for streaming then gets the run object for a simulation run. Signal IDs from the run object specify the signals to be compared.

% Load model slexAircraftExample, and mark signals for streaming
load_system('slexAircraftExample')
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Pilot', 1, 'on')
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Aircraft Dynamics Model', 4, 'on')

% Simulate model slexAircraftExample
sim('slexAircraftExample')

% Get run IDs for most recent run
allIDs = Simulink.sdi.getAllRunIDs;
runID = allIDs(end);

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

% Get signal IDs
signalID1 = run.getSignalIDByIndex(1);
signalID2 = run.getSignalIDByIndex(2);

if (run.isValidSignalID(signalID1))
    % Change signal tolerance
    signal1 = Simulink.sdi.getSignal(signalID1);
    signal1.AbsTol = 0.1;
end

if (run.isValidSignalID(signalID1) && run.isValidSignalID(signalID2))
    % Compare signals
    diff = Simulink.sdi.compareSignals(signalID1, signalID2);

    % Check whether signals match within tolerance
    match = diff.match
end
match =

  logical

   0

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?