Main Content

Simulink.sdi.copyRun

Copy a Simulation Data Inspector run

Description

newRunID = Simulink.sdi.copyRun(runID) copies the run corresponding to runID and returns the run ID for the new run. The new run includes all the simulation data and metadata from the original run. You can modify the copy of the run by adding or deleting signals and metadata while still retaining the original run.

[newRunID,runIndex] = Simulink.sdi.copyRun(runID) copies the run corresponding to runID and returns the run ID and index in the Simulation Data Inspector repository for the new run. The new run includes all the simulation data and metadata from the original run.

example

[newRunID,runIndex,signalIDs] = Simulink.sdi.copyRun(runID) copies the run corresponding to runID and returns the signal IDs for the signals in the new run along with its run ID and index in the Simulation Data Inspector repository. The new run includes all the simulation data and metadata from the original run.

Examples

collapse all

This example shows how to use Simulink.sdi.copyRun and Simulink.sdi.deleteSignal to create a copy of a run that contains a subset of the signals from the original run. You can use the copy to analyze and run comparisons on a subset of signals while still holding onto the original run that has all of the signals. For example, the model sldemo_fuelsys is configured to log ten signals. To compare the system's responses to different types of failures, you don't need to run the comparison on all of the logged signals. Deleting signals that do not represent the system's response before running the comparison saves processing time and simplifies the view of the results.

Create Runs

Load the model sldemo_fuelsys and run simulations to create runs in the Simulation Data Inspector. The first run simulates a failure of the throttle angle sensor, and the second run simulates a failure of the exhaust gas oxygen sensor.

load_system('sldemo_fuelsys')
modelWorkspace = get_param('sldemo_fuelsys','modelworkspace');
modelWorkspace.assignin('throttle_sw',0)
modelWorkspace.assignin('ego_sw',1)
sim('sldemo_fuelsys')

modelWorkspace.assignin('throttle_sw',1)
modelWorkspace.assignin('ego_sw',0)
sim('sldemo_fuelsys')

Copy the Run

Use the Simulation Data Inspector's programmatic interface to get Simulink.sdi.Run objects for the simulations, and then create copies of the runs.

% Get runs
runIDs = Simulink.sdi.getAllRunIDs;

runID1 = runIDs(end-1);
runID2 = runIDs(end);

run1 = Simulink.sdi.getRun(runID1);
run2 = Simulink.sdi.getRun(runID2);

% Create a copy of each run, truncRun
[truncRun1,runIndex1,signalIDs1] = Simulink.sdi.copyRun(runID1);
[truncRun2,runIndex2,signalIDs2] = Simulink.sdi.copyRun(runID2);

Delete Signals in Run Copy

The sldemo_fuelsys model is configured to log the values of the fault switches along with several signals representing the system's response. When you compare the system's response when a throttle angle sensor fails to its response when an exhaust gas oxygen sensor fails, comparing the fault switch states does not provide new information. Therefore, delete the switch signals before running the comparison to eliminate unnecessary computations.

Simulink.sdi.deleteSignal(signalIDs1(1))
Simulink.sdi.deleteSignal(signalIDs1(3))
Simulink.sdi.deleteSignal(signalIDs1(5))
Simulink.sdi.deleteSignal(signalIDs1(8))

Simulink.sdi.deleteSignal(signalIDs2(1))
Simulink.sdi.deleteSignal(signalIDs2(3))
Simulink.sdi.deleteSignal(signalIDs2(5))
Simulink.sdi.deleteSignal(signalIDs2(8))

Compare Truncated Runs

You can use the truncated runs you created with Simulink.sdi.copyRun and Simulink.sdi.deleteSignal to perform a comparison of the system's response to different types of failures. Then, open the Simulation Data Inspector to view the comparison results.

truncRunDiff = Simulink.sdi.compareRuns(truncRun1,truncRun2);

Simulink.sdi.view

Input Arguments

collapse all

Run ID for the run you want to copy. The Simulation Data Inspector assigns run IDs when it creates runs. You can get the run ID for your run using Simulink.sdi.getAllRunIDs or Simulink.sdi.getRunIDByIndex.

Output Arguments

collapse all

Run ID for the copy of the run.

Index of the copy in the Simulation Data Inspector repository.

Matrix containing the signal IDs for the copies of signals created in the copy of the run.

Introduced in R2011b