Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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

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

Output Arguments

expand all

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

Examples

expand all

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

Introduced in R2012b

Was this topic helpful?