Main Content

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. Copy the MAT-files from the Android® device into MATLAB.

    [variable1, variable2] = codertarget.android.internal.getFiles('modelname')

    variable1 is a MATLAB variable that displays the status of copy operation. variable2 displays the list of the MAT-files copied to MATLAB. In an unsuccessful copy operation, variable2 displays the error message.

    For example,

    [result, matFiles] = codertarget.android.internal.getFiles('androidMatFile')
    result =
    
         0
    
    matFiles =
    
        'Successfully pulled following files from device:
         androidMatFile_1_1.mat
         androidMatFile_1_2.mat
         androidMatFile_1_3.mat
         androidMatFile_1_4.mat
         androidMatFile_1_5.mat
         androidMatFile_1_6.mat
         androidMatFile_1_7.mat
         androidMatFile_1_8.mat  
       '

    After successfully copying the files, the value of the result variable becomes 0. The matFiles variable displays the names of the MAT-files copied to MATLAB. You can also see the copied files in the MATLAB Current Folder window.

    If MATLAB encounters any issue when copying the files, the value of the result variable changes to a nonzero value. The matFiles variable displays the corresponding error message.

  2. Load the variables in the MAT-file into MATLAB workspace variables.

    load('modelname*.mat');

    For example,

    load('androidMatFile*.mat');

    After copying the files to MATLAB, 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.

Related Topics