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.
Logged signals as well as outputs and states logged using the
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
Dataset in the Simulation Data Inspector, in the
Model Configuration Parameters
Data Import/Export pane, select the Record logged workspace
data in Simulation Data Inspector option.
When you log states and outputs using the
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.
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. File import supports MAT, CSV, and
Excel® files as well as MDF files with
.dat extensions. The Simulation Data Inspector allows up to 8000
channels per signal in a run created from imported workspace data.
The Simulation Data Inspector can import data from CSV and Microsoft Excel files when the data in the file is formatted according to Import Data from a CSV File into the Simulation Data Inspector or Microsoft Excel Import and Export Format.
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
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.
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.
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.
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
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.
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.
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.