Main Content

px4MATFilestitcher

Combine multiple MAT-files retrieved from SD card into a single MAT-file

Since R2020b

    Add-On Required: This feature requires the UAV Toolbox Support Package for PX4 Autopilots add-on.

    Description

    px4MATFilestitcher() combines all MAT-files, starting with the same file name in the current folder in MATLAB®, into a single MAT-file. The function identifies the first part of the file name that is common for a specific run, and then combine those files in the order determined by the numeric characters present at the end of their file names.

    example

    px4MATFilestitcher(folderpath) combines all MAT-files, starting with the same file name in the folder specified using the full folder path. The function identifies the first part of the file name that is common for a specific run, and then combine those files in the order determined by the numeric characters present at the end of their file names.

    example

    Examples

    collapse all

    Combine all MAT-files that start with the same file name (part of the same run) in the current folder in MATLAB.

    Consider that the file name of the MAT-files start with px4_squarepath_sdcard and that there are nine MAT-files in the current folder in MATLAB, which correspond to three runs, as listed below.

    px4_squarepath_sdcard_1_1.mat
    px4_squarepath_sdcard_1_2.mat
    px4_squarepath_sdcard_1_3.mat
    px4_squarepath_sdcard_2_1.mat
    px4_squarepath_sdcard_2_2.mat
    px4_squarepath_sdcard_2_3.mat
    px4_squarepath_sdcard_3_1.mat
    px4_squarepath_sdcard_3_2.mat
    px4_squarepath_sdcard_3_3.mat

    To combine the files, enter the following command at the MATLAB command prompt:

    px4MATFilestitcher()

    The files are combined based on the run (the suffix after the file name) to generate three stitched files:

    px4_squarepath_sdcard_1_stitched.mat
    px4_squarepath_sdcard_2_stitched.mat
    px4_squarepath_sdcard_3_stitched.mat
    

    For example, all data points logged in px4_squarepath_sdcard_1_1.mat , px4_squarepath_sdcard_1_2.mat , and px4_squarepath_sdcard_1_3.mat are copied to the combined file - px4_squarepath_sdcard_1_stitched.mat .

    Combine all MAT-files that start with the same file name (part of the same run) in any folder that you specify.

    Consider that there is a folder named Today_Runs inside the current folder in MATLAB. The file name of the MAT-files in Today_Runs start with px4_squarepath_sdcard and that there are nine MAT-files in the current folder in MATLAB, which correspond to three runs, as listed below.

    px4_squarepath_sdcard_23_1.mat
    px4_squarepath_sdcard_23_2.mat
    px4_squarepath_sdcard_23_3.mat
    px4_squarepath_sdcard_24_1.mat
    px4_squarepath_sdcard_24_2.mat
    px4_squarepath_sdcard_24_3.mat
    px4_squarepath_sdcard_25_1.mat
    px4_squarepath_sdcard_25_2.mat
    px4_squarepath_sdcard_25_3.mat

    To combine the files, enter the following command at the MATLAB command prompt:

    px4MATFilestitcher(fullfile(pwd,'Today_Runs'))

    The files are combined based on the run (the suffix after the file name) to generate three stitched files:

    px4_squarepath_sdcard_23_stitched.mat
    px4_squarepath_sdcard_24_stitched.mat
    px4_squarepath_sdcard_25_stitched.mat
    

    If the folder Today_Runs is present in a different path other than inside the current folder in MATLAB, specify the full path to combine the files. For example:

    px4MATFilestitcher('C:\User\Autopilot\matfiles\Today_Runs')

    Note

    However, in this case (the folder present in a different path other than inside the current folder in MATLAB), the stitched files are always generated in the current folder in MATLAB.

    Input Arguments

    collapse all

    Absolute path of the folder in the host computer, which contains the MAT-files (which were retrieved from the SD card) that need to be combined.

    Data Types: char | string

    Version History

    Introduced in R2020b