Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Contents

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

signalID

Signal ID, a unique number identifying a signal stored in the run object.

Output Arguments

isValid

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

Examples

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

See Also

| | | | | |

How To

Was this topic helpful?