Import MAT-Files into MATLAB
After logging is complete, you can open MAT-files in MATLAB®, and use them for further analysis. Since the data points are stored in MAT files, you can directly open the files in MATLAB without converting them into any other format.
After the model is deployed on the target hardware:
Remove SD card from the target hardware.
Insert the card into an adapter, and then insert the adapter into the media slot on the computer.
Open the removable disk corresponding to the card on the computer.
In the SD card storage, the files are named as <
modelname
>_
<runnumber
>_
<indexnumber
>.mat
. The name of your Simulink® model ismodelname
.runnumber
is the number of times the model is run.runnumber
starts with1
and is incremented by one for every successive run.indexnumber
is the MAT-file number in a run.indexnumber
starts with1
and is incremented by one for every new file that is created in the same run.Suppose that the name of the model is
sdcard
. In the first run, Simulink createssdcard_1_1.mat
file and starts logging data in this file. After the logging in the first file is completed, Simulink createssdcard_1_2.mat
file and continues logging data in this file. Likewise, the logging continues in multiple MAT-files until the Simulation stop time is elapsed. If the same model is run again, the new files are named assdcard_2_1.mat
,sdcard_2_2.mat
, and so on.Note
Data loss occurs when:
The total file size exceeds the available SD card storage capacity.
The signal logging rate is faster than the SD card writing speed.
To view logged data points, double-click the MAT-files. The MAT-file contains the logged variables, size of the variables (number of elements), size of the variables in bytes and their class.
You can load and plot the data points from these MAT-files using the
load (filename)
andplot (X,Y)
commands for any further data analysis.
Related Examples
- MAT-file Logging on SD Card for STMicroelectronics STM32 Processors (Embedded Coder)
More About
- Log Signals on SD Card (Embedded Coder)
- Prerequisites for Logging Signals (Embedded Coder)
- Enable MAT-File Logging (Embedded Coder)
- Configure Model to Log Signals on SD Card (Embedded Coder)
- Run Model on Target Hardware (Embedded Coder)