Main Content

getSignalIDByIndex

Get signal ID for signal at specified index in Simulink.sdi.Run object

Description

sigID = getSignalIDByIndex(runObj,idx) returns the signal ID sigID for the signal at the specified index idx in the Simulink.sdi.Run object runObj.

Tip

You can use the signal ID to get the Simulink.sdi.Signal object that contains the signal data and metadata or perform a signal comparison using the Simulink.sdi.compareSignals function.

example

Examples

collapse all

You can use the Simulation Data Inspector programmatic interface to compare signals within a single run. This example compares the input and output signals of an aircraft longitudinal flight controller.

Load the Simulation Data Inspector session file that contains the flight control data.

Simulink.sdi.load("AircraftExample.mldatx");

To access the latest run, use the Simulink.sdi.Run.getLatest function.

aircraftRun = Simulink.sdi.Run.getLatest;

Use the Simulink.sdi.getSignalsByName function to access the Stick signal, which represents the input to the controller, and the alpha, rad signal, which represents the output.

stick = getSignalsByName(aircraftRun,"Stick");
alpha = getSignalsByName(aircraftRun,"alpha, rad");

Use the signal IDs to compare the Stick and alpha, rad signals using the Simulink.sdi.compareSignals function. The Stick signal is the baseline. The alpha, rad signal is the signal to compare against the baseline.

comparisonResults = Simulink.sdi.compareSignals(stick.ID,alpha.ID);
match = comparisonResults.Status
match = 
  ComparisonSignalStatus enumeration

    OutOfTolerance

The comparison result is out of tolerance. You can use the Simulink.sdi.view function to open the Simulation Data Inspector to view and analyze the comparison results.

Simulink.sdi.view

Comparison of the stick and alpha, rad signals

You can specify time and magnitude tolerance values to use for the comparison. Comparisons use tolerance values specified for the baseline signal in the comparison. To account for the phase shift, set a time tolerance of 1 on the Stick signal. To account for magnitude differences, set an absolute tolerance value of 0.1 on the Stick signal.

stick.TimeTol = 1;
stick.AbsTol = 0.1;

Compare the signals again. This time, because of the absolute and time tolerances, the signal comparison passes.

comparisonResults = Simulink.sdi.compareSignals(stick.ID,alpha.ID);
match = comparisonResults.Status
match = 
  ComparisonSignalStatus enumeration

    WithinTolerance

Comparison of the Stick and alpha, rad signals using a time tolerance of 1 and an absolute tolerance of 0.1

Input Arguments

collapse all

Run that contains the desired signal, specified as a Simulink.sdi.Run object.

Index of the signal within the run, specified as an integer.

Output Arguments

collapse all

Unique numeric signal identifier, returned as an integer.

Version History

Introduced in R2012b