Documentation

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

expand all

signalID — Signal identifierinteger

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

Output Arguments

expand all

signalObj — Signal objectobject

A signal within a run object, Simulink.sdi.Run, returned as a Simulink.sdi.Signal object.

Examples

expand all

Plot Signals In a Run

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

Related Examples

Introduced in R2012b

Was this topic helpful?