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.

  1. In your hardware, go to the location specified in Simulation > Model Configuration Parameters > Hardware Implementation > Target hardware resources > Build options > Build directory. The default location where the MAT-files are saved is /home/debian/SDcard.

    The files are named as <modelname>_<runnumber>_<indexnumber>.mat. The name of your Simulink® model is modelname. 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, Simulink creates 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 mutiple MAT-files until the Simulation stop time is elapsed. If the same model is run again, the new files are named as sdcard_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.

  2. Create a beagleboneblue object. In the MATLAB command window, type this command.

    b = beagleboneblue(<IPaddress>,<username>,<password>)

    For example,

    b = beagleboneblue('192.168.7.2','debian','temppwd')

    The parameters specified in this command must match the board parameters specified in Simulation > Model Configuration Parameters > Hardware Implementation > Hardware board settings > Target hardware resources > Board Parameters.

  3. To copy a MAT-file from the hardware to the computer, use the getFile command.

    getFile(b,<modelname>.mat)

    For example,

    getFile(b,'/home/debian/SDcard/sdcard0.mat')

    Here, b specifies the beagleboneblue object and modelname specifies the path and name of the file on the hardware.

    To copy all the MAT-files from the hardware to the computer specify * in the getFile command.

    getFile(b,<modelname>*.mat)

    For example,

    getFile(b,'/home/debian/SDcard/sdcard*.mat')

    Here, * copies all the files having names that start with <modelname> and ends with .mat.

    After copying the files to the computer, you can use them like conventional MAT-files. For example, you can load and plot data points using the load and plot commands in the MATLAB command window.