Contents

getSignal

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

Return Simulink.sdi.Signal object by signal ID

Syntax

signalObj = runObj.getSignal(signalID)

Description

signalObj = runObj.getSignal(signalID) returns the Simulink.sdi.Signal object, signalObj, corresponding to the signal ID, signalID, stored in the Simulink.sdi.Run object, runObj.

Input Arguments

signalID

Signal ID, a unique number identifying a signal in a run in the Simulation Data Inspector.

Output Arguments

signalObj

Handle to a Simulink.sdi.Signal object representing a signal in a run object, Simulink.sdi.Run.

Examples

The Simulink.sdi.Run method, getSignal, returns a signal object representing the signal data and metadata in a run. You can modify the signal object properties to configure the signal for plotting or comparing to other signals in the Simulation Data Inspector.

% Configure model "slexAircraftExample" for logging and simulate
simOut = sim('slexAircraftExample', 'SaveOutput','on', ...
               'SaveFormat', 'StructureWithTime', ...
               'ReturnWorkspaceOutputs', 'on');
 
% Create a Simulation Data Inspector run
[runID,runIndex,signalIDs] = 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 Simulink.sdi.Signal objects for each signal in the run and select for plotting 
for i = 1:numSignals
   signalObjs(i) = runObj.getSignal(signalIDs(i));
   signalObjs(i).checked = true;
end
Was this topic helpful?