Documentation

isValidSignalID

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

Determine if signal ID is valid within run

Syntax

isValid = runObj.isValidSignalID(signalID)

Description

isValid = runObj.isValidSignalID(signalID) returns true if the signal ID, signalID, corresponds to a signal in the run object, runObj. Otherwise, it returns false.

Input Arguments

expand all

signalID — Signal identifierinteger

Unique number identifying a signal stored in the run object, specified as an integer.

Output Arguments

expand all

isValid — Valid signal indicatorboolean

A Boolean value: true, if the signal exists; false, otherwise.

Examples

expand all

Check That a Signal ID Is Valid

Before calling a function that takes a signal ID as input, verify that the signal ID is valid.

% 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

% Before calling getSignal, check that the signalID is valid 
if runObj.isValidSignalID(signalID)
	   signalObj = runObj.getSignal(signalID)
end

Related Examples

Introduced in R2012b

Was this topic helpful?