Main Content

Simulink.sdi.getSignal

Get Simulink.sdi.Signal object for a signal

Description

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.

example

Examples

collapse all

You can create a run in the Simulation Data Inspector using data from the workspace.

Generate Data for Run

Create timeseries data for sine and cosine signals. Give each signal a descriptive name.

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 Run and Return Signal IDs

Use the Simulink.sdi.createRun function to create a run for the sinusoid data. You can use multiple return arguments to get the run ID, run index, and signal IDs directly. If you do not return the signal ID using the Simulink.sdi.createRun function, you can access the signal IDs through the Simulink.sdi.Run object.

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

Modify Signal Properties and View in Simulation Data Inspector

Use the second signal ID in the returned sigIDs vector to get the Simulink.sdi.Signal object corresponding to the cosine wave.

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

You can view and modify the signal properties for a Simulink.sdi.Signal object. For example, set the Checked property of cosSig to true to plot the signal in the Simulation Data Inspector. Then, open the Simulation Data Inspector to view the signal data.

cosSig.Checked = true;
Simulink.sdi.view

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.

Version History

Introduced in R2011b