Main Content

Save Simulation Data Inspector session


example saves all runs, signals, and visualization settings as a Simulation Data Inspector session in the file fileName.

A session file includes data as well as visualization information. Use the Simulink.sdi.load function to open a session file in the Simulation Data Inspector. When the session file opens, you can choose to add the data to existing data in the Simulation Data Inspector or clear the existing data.

You can also save only the visualization information to apply to other sets of data. Save visualization information for reuse in a view file using the Simulink.sdi.saveView function.


collapse all

This example creates, saves, and loads a Simulation Data Inspector session. The example logs data in the model slexAircraftExample and visualizes the logged data in a Simulation Data Inspector session. Each time you use the Simulation Data Inspector, you create and modify a session. You can save the data and associated visualization settings for a session in an MLDATX file using the function. When you want to review the data later, you can load the session using the Simulink.sdi.load function.

Log Data to the Simulation Data Inspector

This example logs data from a simulation of the model slexAircraftExample to the Simulation Data Inspector. The model is not configured to log data. Load the model and mark the Stick, the alpha, rad, and the q, rad/sec signals for logging.


Simulink.sdi.markSignalForStreaming('slexAircraftExample/Aircraft Dynamics Model',3,'on')
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Aircraft Dynamics Model',4,'on')

For this example, run two simulations of the model. In the first simulation, use the sine wave output from the Pilot block, and in the second, use the square wave output.



Visualize the Logged Data

You can use the Simulation Data Inspector programmatic interface to access the logged data from the simulations. When you access data using the Simulation Data Inspector programmatic interface, you can use functions to create plots in the Simulation Data Inspector.

To start, access the run IDs for the most recent two runs and then get the corresponding Simulink.sdi.Run object. The Run objects allow you to access the logged data for the simulations.

runIDs = Simulink.sdi.getAllRunIDs;
sineRunID = runIDs(end-1);
squareRunID = runIDs(end);

sineRun = Simulink.sdi.getRun(sineRunID);
squareRun = Simulink.sdi.getRun(squareRunID);

Suppose you want to analyze the relationship between the input and output for the model. Get the Simulink.sdi.Signal objects for the input and output signals from the two simulation runs.

sineOut = getSignalByIndex(sineRun,1);
sineIn = getSignalByIndex(sineRun,3);

squareOut = getSignalByIndex(squareRun,1);
squareIn = getSignalByIndex(squareRun,3);

Change the subplot layout in the Simulation Data Inspector to 2-by-1 and plot the signals from the first simulation run on the top plot and the signals from the second run on the bottom plot.




Save the Simulation Data Inspector Session

To view the plotted data in the Simulation Data Inspector, enter Simulink.sdi.view in the command window.

Then, save the Simulation Data Inspector session as an MLDATX file.'myData.mldatx')

Load the Simulation Data Inspector Session

To mimic a scenario where you want to return to looking at the same data at a later point, clear the data from the Simulation Data Inspector and reset the subplot layout to 1-by-1.


Load the session file and resume working with the data. You can open the Simulation Data Inspector and view the results using the Simulink.sdi.view function.


Input Arguments

collapse all

Name for the session file.

Example: 'myData.mldatx'

Version History

Introduced in R2011b