View Data with the Simulation Data Inspector

The Simulation Data Inspector can visualize many kinds of data that you generate throughout your design process, including complex, event, and frame data. You can log your data to the Simulation Data Inspector from a Simulink® model, or you can import data from the base workspace or a MAT-, CSV-, or MDF-file. Visualizing your data with the Simulation Data Inspector supports design, debugging, and verification workflows. You can also create custom visualizations of data during simulations using data access. For more information see, Access Data in a MATLAB Function During Simulation.

View Logged Data

Simulink sends data for logged signals and outputs to the workspace and to the Simulation Data Inspector.

Open the model slexAircraftExample by typing its name at the MATLAB® command line.

To log the q, rad/sec and alpha, rad signals, select the signals. Right-click the selected signals, and select Log Selected Signals from the context menu. The logging badge marks the signals in the model.

Alternatively, you can select signals to log using one of the several methods described in Mark a Signal for Logging.

Run a simulation. Change the Pilot block's Wave form to sine, and simulate the model again. Then, open the Simulation Data Inspector by clicking the Data Inspector button on the Simulink Toolstrip.

The Simulation Data Inspector creates a run for the data from each simulation. The two runs and their signals are listed on the left in the Inspect pane. By default, the Simulation Data Inspector automatically archives previous simulation runs, and the run for the first simulation is in the Archive. You can plot signals from the archive, or you can move runs of interest from the archive into the work area. Drag Run 1 into the work area.

The Simulation Data Inspector keeps signal line styles and colors consistent for every run. Click the lines next to the signals in Run 1 in the Inspect pane, and change the colors. Then, select the check boxes next to the alpha, rad signals in both runs.

You can also select signals to plot in your model. When you click the logging badge for a signal during or after a simulation, the Simulation Data Inspector plots the signal on the active subplot.

States and Simscape™ data do not log directly to the Simulation Data Inspector and can be recorded instead. Recorded data accumulates during simulation and then automatically imports into the Simulation Data Inspector when the simulation pauses or completes. Data must be logged to the workspace to record to the Simulation Data Inspector. To configure logged data for recording, select Record logged workspace data in Simulation Data Inspector in the Data Import/Export pane of the Model Configuration Parameters.

Note

To record States, Dataset is the recommended Format. You can also set Format to Structure with time or Array. If Format is configured as Array, you must also log Time for States to record to the Simulation Data Inspector.

View Data from the Workspace or a File

You can import data to view in the Simulation Data Inspector from the base workspace or a MAT, CSV, or Microsoft® Excel® file. For information about how to format the data in CSV and Microsoft Excel files for import into the Simulation Data Inspector, see Simulation Data Inspector Import and Export File Format. You can also import MDF-files with mdf, mf4, mf3, data, and dat file extensions. The Simulation Data Inspector allows up to 8000 channels per signal in a run created from imported workspace data.

This example shows how to import a MAT-file containing saved data from a previous simulation to view alongside a current simulation. You can also import data created outside of Simulink, like measured test data, for example.

To import data, you have to open the Simulation Data Inspector. Type Simulink.sdi.view in the MATLAB Command Window, or you can click the Data Inspector button in the Simulink Editor.

Then, to import data:

  1. Click the Import button on the left sidebar.

  2. Select import from File.

  3. To import the previous simulation data to a new run, select New run. You can also import data to an existing run.

  4. Click Import.

    The imported run appears in the work area, with the current simulation run. The Simulation Data Inspector always puts imported data in the work area, and you can manually move imported runs to the archive.

Tip

To work with data vectors, the Simulation Data Inspector requires at least an associated time vector for your data. In general, the Array and Structure data formats are not supported unless Time is logged. The Timeseries data format is preferred because some of the Simulation Data Inspector features work best with metadata that is missing from other formats.

Select the check boxes next to the slp signal in each run to view the signals.

View Complex Data

To view complex data in the Simulation Data Inspector, import the data or log the signals to the Simulation Data Inspector. You can control how to visualize the complex signal using the Properties pane in the Simulation Data Inspector and in the Instrumentation Properties for the signal in the model. To access the Instrumentation Properties for a signal, right-click the logging badge for the signal and select Properties.

You can specify the Complex Format as Magnitude, Magnitude-Phase, Phase, or Real-Imaginary. If you select Magnitude-Phase or Real-Imaginary for the Complex Format, the Simulation Data Inspector plots both components of the signal when you select the check box for the signal. For signals in Real-Imaginary format, the Line Color specifies the color of the real component of the signal, and the imaginary component is a different shade of the Line Color. For example, the Rectangular QAM Modular Baseband signal on the lower graph displays the real component of the signal in light blue, matching the Line Color parameter, and the imaginary component is shown in a darker shade of blue.

For signals in Magnitude-Phase format, the Line Color specifies the color of the magnitude component, and the phase is displayed in a different shade of the Line Color.

View String Data

You can log and view string data with your signal data in the Simulation Data Inspector. For example, consider this simple model. The value of the sine wave block controls whether the switch sends a string reading Positive or Negative to the output.

The plot shows the results of simulating the model. The string signal is shown at the bottom of the graphical viewing area. The value of the signal is displayed inside a band, and transitions in the string signal's value are marked with criss-crossed lines.

You can use cursors to inspect how the string signal values correspond with the sine signal's values.

When you plot multiple string signals on a plot, the signals stack in the order they were simulated or imported, with the most recent signal positioned at the top. For example, you might consider the effect of changing the phase of the sine wave controlling the switch.

View Frame-Based Data

Processing data in frames rather than point by point provides a performance boost needed in some applications. To view frame-based data in the Simulation Data Inspector, you have to specify that the signal is frame-based in the Instrumentation Properties for the signal. You can access the Instrumentation Properties dialog for a signal by right-clicking the signal's logging badge, and selecting Properties. To specify a signal as frame-based, select Columns as channels (frame based) for Input processing.

View Event-Based Data

You can log or import event data to the Simulation Data Inspector. To view the logged event-based data, select the check box next to Send: 1. The Simulation Data Inspector displays the data as a stem plot, with each stem representing the number of events that occurred for a given sample time.

Related Topics