View Data in the Simulation Data Inspector
You can use the Simulation Data Inspector to visualize the data you generate throughout the design process. Simulation data that you log in a Simulink® model logs to the Simulation Data inspector. You can also import test data and other recorded data into the Simulation Data Inspector to inspect and analyze it alongside the logged simulation data. The Simulation Data Inspector offers several types of plots, which allow you to easily create complex visualizations of your data.
View Logged Data
Logged signals as well as outputs and states logged using the Dataset
format automatically log to the Simulation Data Inspector when you simulate a model. You
can also record other kinds of simulation data so the data appears in the Simulation
Data Inspector at the end of the simulation. To see states and output data logged using
a format other than Dataset
in the Simulation Data Inspector, open
the Configuration Parameters dialog box and, in the Data
Import/Export pane, select the Record logged workspace data in
Simulation Data Inspector parameter.
Note
When you log states and outputs using the Structure
or Array
format, you must also log time for the data to record to the Simulation Data Inspector.
The Simulation Data Inspector displays available data in the table in the Inspect pane. To plot a signal, select the check box next to the signal. You can modify the layout and add different visualizations to analyze the simulation data. For more information, see Create Plots Using the Simulation Data Inspector.
The Simulation Data Inspector manages incoming simulation data using the archive. By default, the previous run moves to the archive when you start a new simulation. You can plot signals from the archive, or you can drag runs of interest back into the work area.
Import Data from the Workspace or a File
You can import data from the base workspace or from a file to view on its own or alongside simulation data. The Simulation Data Inspector supports all built-in data types and many data formats for importing data from the workspace. In general, whatever the format, sample values must be paired with sample times. The Simulation Data Inspector allows up to 8000 channels per signal in a run created from imported workspace data.
You can also import data from these types of files:
MAT file
CSV file — Format data as shown in Import Data from a CSV File into the Simulation Data Inspector.
Microsoft® Excel® file — Format data as described in Microsoft Excel Import, Export, and Logging Format.
MDF file — MDF file import is supported for Linux® and Windows® operating systems. The MDF file must have a
.mdf
,.mf4
,.mf3
,.data
, or.dat
file extension and contain data with only integer and floating data types.ULG file — Flight log data import requires a UAV Toolbox license.
To import data from the workspace or from a file that is saved in a data or file format that the Simulation Data Inspector does not support, you can write your own workspace data or file reader to import the data using the io.reader
class. You can also write a custom reader to use instead of the built-in reader for supported file types. For examples, see:
To import data, select the Import button in the Simulation Data
Inspector.
In the Import dialog, you can choose to import data from the workspace or from a file. The table below the options shows data available for import. If you do not see your workspace variable or file contents in the table, that means the Simulation Data Inspector does not have a built-in or registered reader that supports that data. You can select which data to import using the check boxes, and you can choose whether to import that data into an existing run or a new run. To select all or none of the data, use the check box next to NAME.
When you import data into a new run, the run always appears in the work area. You can manually move imported runs to the archive.
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 Complex Signal
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. To access the Instrumentation Properties dialog for a signal, right-click the signal's logging badge and select 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.