Get Simulink.sdi.Signal object for a signal



signalObj = Simulink.sdi.getSignal(sigID) returns a Simulink.sdi.Signal object for the signal in the Simulation Data Inspector repository that corresponds to the signal ID, sigID. The Simulink.sdi.Signal object manages signal data and metadata and allows you to view and modify signal properties.


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',...

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;

Input Arguments

collapse all

Signal identifier. The Simulation Data Inspector assigns signal IDs to signals when a run is created. You can get the signal ID for a signal as a return from Simulink.sdi.createRun or using the Simulink.sdi.Run object's methods.

Output Arguments

collapse all

Simulink.sdi.Signal object for the signal corresponding to sigID.

Introduced in R2011b