Simulink.sdi.createRunOrAddToStreamedRun

Create a single run for all simulation outputs

Description

example

runID = Simulink.sdi.createRunOrAddToStreamedRun(mdl,runName,varSources,varValues) creates a run with the data varValues if no run exists in the Simulation Data Inspector repository for the model mdl. If one or more runs for the model mdl exist in the Simulation Data Inspector repository, the function adds varValues to the most recent run associated with mdl. The run is named according to runName, and the sources for the data in varValues are named according to varSources.

Examples

collapse all

This example shows how to use Simulink.sdi.createRunOrAddToStreamedRun to add data to an existing run for a model. In this example, you add logged states data to the run created through simulation.

Simulate the Model

Simulate the model to generate data. The model slexAircraftExample is configured to log outputs, so the Simulation Data Inspector automatically creates a run with the logged outport data. Using this simulation syntax, out contains the outport data (yout) and the states data (xout).

load_system('slexAircraftExample')
out = sim('slexAircraftExample','ReturnWorkspaceOutputs','on',...
            'SaveFormat','Dataset');

Add Logged States Data to Run

The Simulation Data Inspector automatically created a run for the logged outport data. Add the logged state data to the existing run using Simulink.sdi.createRunOrAddToStreamedRun.

Simulink.sdi.createRunOrAddToStreamedRun('slexAircraftExample','Run 1',...
              {'out'},{out});

Open the Simulation Data Inspector to View Results

Using Simulink.sdi.createRunOrAddToStreamedRun avoids redundancy in the data shown in the Simulation Data Inspector. Using Simulink.sdi.createRun to bring the states data into the Simulation Data Inspector creates a second run. Simulink.sdi.addToRun creates a duplicate signal from the outport data. Using Simulink.sdi.createRunOrAddToStreamedRun, you can include all simulation data in a single run without duplicating any signals.

Simulink.sdi.view

Input Arguments

collapse all

Name of the model the simulation data is from, specified as a character vector.

Example: 'sldemo_absbrake'

Name for the new or augmented run. If Simulink.sdi.createRunOrAddToStreamedRun adds data to an existing run, the run is renamed according to runName.

Example: 'Run 1'

Names for the sources of the data in varValues.

Example: {'sig1','sig2'}

Cell array of data to incorporate into the run. Simulink.sdi.createRunOrAddToStreamedRun supports data in all logging and loading formats, including timeseries and Simulink.SimulationData.Dataset.

Example: {sig1,sig2}

Output Arguments

collapse all

Run identifier for the new or augmented run.

Introduced in R2017a