Main Content

getAllSignals

Get all signals in Simulink.sdi.Run object

Description

example

sigs = getAllSignals(runObj) returns an array of Simulink.sdi.Signal objects, sigs, that correspond to the signals contained in the Simulink.sdi.Run object runObj. Use the getAllSignals function when you need to work with many or all of the signals in the run. When you need to analyze a specific signal, you can access the single Signal object using the getSignalsByName function or the getSignalByIndex function.

Examples

collapse all

You can use the getAllSignals function to access Simulink.sdi.Signal objects for each signal in a Simulink.sdi.Run object when you want to analyze all the data in the run. This example shows how to access and inspect signal data logged in the sldemo_autotrans model.

Create a Run

This example creates a run in the Simulation Data Inspector by simulating a model that logs data.

out = sim('sldemo_autotrans');

Access Run and Signal Data

Access the run and signal data using the Simulation Data Inspector programmatic interface. Use the Simulink.sdi.getCurrentSimulationRun function to get the Run object created when you simulated the sldemo_autotrans model.

autoRun = Simulink.sdi.getCurrentSimulationRun('sldemo_autotrans');

Use the getAllSignals function to get an array of Signal objects containing the logged signal data.

autoSigs = getAllSignals(autoRun);

You can use a for loop to inspect or analyze the data in each Signal object in the array. For example, you could check the name of each signal.

count = length(autoSigs);
for idx = 1:count
    sig = autoSigs(idx);
    name = sig.Name;
    formatSpec = "The signal at index %d is named %s\n";
    fprintf(formatSpec,idx,name)
end
The signal at index 1 is named EngineRPM
The signal at index 2 is named Throttle
The signal at index 3 is named BrakeTorque
The signal at index 4 is named ShiftLogic:1
The signal at index 5 is named ImpellerTorque
The signal at index 6 is named OutputTorque
The signal at index 7 is named VehicleSpeed
The signal at index 8 is named TransmissionRPM

Input Arguments

collapse all

Run containing the signals you want to access, specified as a Simulink.sdi.Run object.

Output Arguments

collapse all

Signals contained in the run, returned as an array of Simulink.sdi.Signal objects.

Introduced in R2020a