Simulink.sdi.addToRun

Add one or more signals to existing run

Description

example

sigIDs = Simulink.sdi.addToRun(runID,'vars',var,var2,...,varn) adds the data in the variables var,var2,...,varn to the run corresponding to the runID and returns the signal IDs for the signals added to the run.

sigIDs = Simulink.sdi.addToRun(runID,sourceNames,dataValues) adds the data in the cell array dataValues to the run corresponding to the runID and returns the signal IDs for the signals added to the run. The sourceNames argument specifies names to use for the source of the data in dataValues in the signal metadata.

Examples

collapse all

This example shows how to use Simulink.sdi.addToRun to add workspace data to a run in the Simulation Data Inspector.

Generate Workspace Data

Generate workspace data to add to a simulation run in place of measured data, input data, or any other data that you want to associate with the simulation.

time = linspace(0, 60, 201);
cos_vals = 2*cos(2*pi/6.8*time);
cos_ts = timeseries(cos_vals, time);
cos_ts.Name = 'cosine';

Simulate Model

Simulate the slexAircraftExample model to create a run containing the simulation outputs.

load_system('slexAircraftExample');
sim('slexAircraftExample','SaveFormat','Dataset');

Add Workspace Data to Simulation Run

Add the workspace data to the run. Then, view the results in the Simulation Data Inspector.

% Get run ID
count = Simulink.sdi.getRunCount;
runID = Simulink.sdi.getRunIDByIndex(count);

% Add data to run
sigIDs = Simulink.sdi.addToRun(runID,'vars',cos_ts);

Simulink.sdi.view

Input Arguments

collapse all

Run ID for the signal you want to add data to. The Simulation Data Inspector assigns a unique run ID when it creates a run. You can get the run ID for your run using Simulink.sdi.getAllRunIDs and Simulink.sdi.getRunIDByIndex.

Workspace data to add to the run. Simulink.sdi.addToRun supports all loading and logging data formats, including timeseries and Simulink.SimulationData.Dataset. Provide one or more var inputs when you specify 'vars' as the second argument.

Example: myData

Names to use as the source of the data in the metadata for the added signals. Provide a sourceNames input when you specify 'namevalue' as the second argument.

Example: {'speed','position'}

Cell array of data to add to the run. Provide a dataValues input when you specify 'namevalue' as the second argument.

Example: {sig1,sig2}

Output Arguments

collapse all

Matrix of signal IDs for signals added to the run.

Introduced in R2011b