Import Data from Workspace or File into Simulation Data Inspector
You can import data into the Simulation Data inspector from the base workspace or from a file. Using the Simulation Data Inspector, you can view imported data on its own or alongside other simulation data.
The Simulation Data Inspector supports all built-in data types and many data formats, such
as Dataset
, timeseries
, and
timetable
, for importing data from the workspace. Whatever the
format, sample values generally 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 import data from many different types of files, including:
MAT files
CSV files — Format data as shown in Import Data from a CSV File into the Simulation Data Inspector.
Microsoft® Excel® files — Format data as described in Microsoft Excel Import, Export, and Logging Format.
MDF files — MDF file import is supported for Linux® and Windows® operating systems. The MDF file must have a
.mdf
,.mf4
, or.dat
file extension and contain only integer, floating-point, and string data types in the MDF file channels.ULG files — Flight log data import requires a UAV Toolbox license.
ROS Bag files — ROS Bag file import is supported for file versions 1.1 and 2.0. Bag file import requires a ROS 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:
Import Data From Workspace
You can import time-based data from the workspace into the Simulation Data Inspector. Create timeseries
objects that contain data for a sine signal and a cosine signal. Give each timeseries
object a descriptive name.
time = 0:0.1:10; sinVals = sin(time); cosVals = cos(time); sinTS = timeseries(sinVals,time,"Name","Sine"); cosTS = timeseries(cosVals,time,"Name","Cosine");
Open the Simulation Data Inspector.
Simulink.sdi.view
To import data interactively, in the Simulation Data Inspector, select Import . In the Import dialog box, 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.
In the Import dialog box:
Under Import from, select Base workspace.
Under To, select New run.
In the signal table, select the
Sine
andCosine
signals.Click Import.
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.
Select signals from the signal table to view data in the Simulation Data Inspector. To create two vertically aligned subplots, click Visualizations and layouts . Then, under Basic layouts, select a 2x1
subplot layout. Plot the Cosine
signal in the upper subplot and plot the Sine
signal in the lower subplot.
Import Data From File
The MAT-file fuelsysRunData
contains signal data from one run of the sldemo_fuelsys
model. For more information about the model, see Model Fault-Tolerant Fuel Control System.
Open the Simulation Data Inspector.
Simulink.sdi.view
To import data from the fuelsysRunData
file into the Simulation Data Inspector, click Import . In the Import dialog box:
Under Import from, select File. Then, type the file name or navigate the file system to select the
FuelsysRunData
file.Under To, select New run.
In the signal table, select the checkbox next to NAME to select all the signals.
Click Import.
In the Simulation Data Inspector, use the sparklines visualization to view the data. Click Visualizations and layouts . Then, under Visualizations, select Sparklines. Select signals from the signal table to view them in the sparklines plot.