Simulink.sdi.getSignal

Get Simulink.sdi.Signal object for a signal

Description

example

signalObj = Simulink.sdi.getSignal(sigID) returns a Simulink.sdi.Signal object for the signal in the Simulation Data Inspector that corresponds to the signal ID, sigID.

Examples

collapse all

This example shows how to access signal data when you create a run in the Simulation Data Inspector.

Generate Data for Run

For this example, create timeseries data for sine and cosine signals.

% Create timeseries workspace data
time = linspace(0, 20, 101);

sine_vals = sin(2*pi/5*time);
sine_ts = timeseries(sine_vals,time);
sine_ts.Name = 'Sine, T=5';

cos_vals = cos(2*pi/8*time);
cos_ts = timeseries(cos_vals,time);
cos_ts.Name = 'Cosine, T=8';

Create a Run and Return Signal IDs

You can use the Simulink.sdi.createRun syntax with multiple return arguments to get the signal IDs more directly instead of accessing the signal IDs through a Simulink.sdi.Run object.

[runID,runIndex,sigIDs] = Simulink.sdi.createRun('Sinusoids','vars',...
    sine_ts,cos_ts);

cosID = sigIDs(2);
cosSig = Simulink.sdi.getSignal(cosID);

Modify Signal Properties and View in the Simulation Data Inspector

You can use the Simulink.sdi.Signal object to view and modify signal properties and to plot signals in the Simulation Data Inspector.

cosSig.Checked = true;
cosSig.AbsTol = 0.05;
Simulink.sdi.view
cosSig.Name

Input Arguments

collapse all

Unique, numeric signal identifier, specified as an integer. The Simulation Data Inspector assigns a signal ID to each signal when a run is created. You can get the signal ID for a signal using one of these functions:

Output Arguments

collapse all

Signal that corresponds to the signal ID, sigID, returned as a Simulink.sdi.Signal object.

Introduced in R2011b