Main Content

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 data logged using the Structure with Time format to a run that contains logged signal data.

Simulate the Model

Open the slexAircraftExample model and mark the output of the Pilot block for logging. The logged signal data uses the Dataset format and streams to the Simulation Data Inspector during simulation. The model is configured to log outputs, states, and time as well as signals. Simulate the model and return a single output in the workspace with all the logged data. Use the Structure with Time format for logged states and outputs.

load_system('slexAircraftExample')

Simulink.sdi.markSignalForStreaming('slexAircraftExample/Pilot',1,1)

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

Add Logged States Data to Run

The Simulation Data Inspector automatically created a run for the logged signal data. Add the logged states and outputs 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

Use the Simulink.sdi.view function to open the Simulation Data Inspector and view the results.

Using Simulink.sdi.createRunOrAddToStreamedRun avoids redundancy in the data shown in the Simulation Data Inspector. When you use the Simulink.sdi.createRun function to import the output and states data, the Simulation Data Inspector creates a second run. When you use the Simulink.sdi.addToRun function to add the logged states and output data to the run, the Simulation Data Inspector imports a duplicate of the Pilot block output signal. Using Simulink.sdi.createRunOrAddToStreamedRun, you can include all simulation data in a single run without duplicating any signals.

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