Clear all data from the Simulation Data Inspector



Simulink.sdi.clear clears all plotted signals and deletes all data from the Simulation Data Inspector. The Simulink.sdi.clear function does not affect preferences or settings you have configured in the Simulation Data Inspector. Use the Simulink.sdi.clearPreferences function to reset the Simulation Data Inspector preferences to their default values. Use the Simulink.sdi.clearAllSubPlots function to clear all plotted signals without deleting any data from the Simulation Data Inspector.


collapse all

This example shows how to create, save, and load a Simulation Data Inspector session. The example uses data logging to populate the Simulation Data Inspector with data and then uses the Simulation Data Inspector's programmatic interface to create plots to visualize the data. After saving the data and visualization settings in a session, the Simulation Data Inspector repository is emptied in order to demonstrate how to load the session.

Create Simulation Data

This example logs the Stick, alpha, rad, and q, rad/sec signals to generate simulation data using the model slexAircraftExample and creates two runs. The first uses a sine input, and the second has a square wave input.

% Ensure you start with an empty Simulation Data Inspector repository

% Load system

% Configure signals to log
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Aircraft Dynamics Model',3,'on')
Simulink.sdi.markSignalForStreaming('slexAircraftExample/Aircraft Dynamics Model',4,'on')

% Change Pilot signal to sine

% Simulate model

% Change Pilot signal to square

% Simulate model

Access Simulation Data

Use the Simulation Data Inspector programmatic interface to access the simulation data so you can create plots to visualize the signals.

% Get run objects
runIDs = Simulink.sdi.getAllRunIDs;
sineRunID = runIDs(end-1);
squareRunID = runIDs(end);

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

% Get signal objects
sineOut = sineRun.getSignalByIndex(1);
sineIn = sineRun.getSignalByIndex(3);

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

Create Plots in the Simulation Data Inspector

Use the programmatic interface to visualize the signal data from the two simulation runs. You can set the plot layout and plot signals on specific subplots.

% Set subplot layout 

% Plot sine data on top plot

% Plot square wave data on bottom plot

Save a Simulation Data Inspector Session

First, view the plots you just created. Then, save the Simulation Data Inspector session as an MLDATX-file to recover your data along with your preference selections and plots.

% View the visualized data in the Simulation Data Inspector

% Save the Simulation Data Inspector session'myData.mldatx')

Load a Simulation Data Inspector Session

First, clear the Simulation Data Inspector repository with Simulink.sdi.clear and reset visualization settings with Simulink.sdi.clearPreferences. Then, you can load the session to see how the data and settings are preserved.

% Clear Simulation Data Inspector repository and preferences

% Load session file to view data

Introduced in R2011b