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.
Remove the SD Card from the VEX® EDR V5 Robot Brain, connect the card to the host computer and read the .mat files from the explorer.
The files are named as
The name of your Simulink® model is
runnumber is the number of times
the model is run.
runnumber starts with
1 and is
incremented by one for every successive run.
indexnumber is the
MAT-file number in a run.
indexnumber starts with
1 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,
sdcard_1_1.mat file and starts logging data in this file. After
the logging in the first file is completed, Simulink creates
sdcard_1_2.mat file and continues
logging data in this file. Likewise, the logging continues in multiple MAT-files until
the Stop time is elapsed. If the same model is run again, the new
files are named as
and so on.
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.
Combine MAT-files and Analyze Variables
You need to combine all the MAT-files obtained from the SD card into a single
MAT-file by using the
VEXV5_MAT_stitcher command, and then
analyze the variables for logged data.
Run the following command at the MATLAB prompt:
dirrepresents the absolute path of the directory that contains the MAT-files.
This command combines all the MAT-files starting with the same name in the current directory into a single file. The order of the stitching is based on the numeric characters found at the end of the file name. The name of the stitched file ends with
Load the stitched MAT-file. For example, run the below command if the name of the stitched file is
To view the logged values, double-click the corresponding variable that appears in the Workspace window.