process a list of files with a specific extension name in matlab

后端 未结 4 1559
甜味超标
甜味超标 2020-12-05 20:00

How can I process all the files with \".xyz\" extension in a folder? The basic idea is that I want a list of file names and then a for loop to load each file.

4条回答
  •  被撕碎了的回忆
    2020-12-05 20:15

    Here is my answer:

    dirName = 'E:\My Matlab\5';
    [sub,fls] = subdir(dirName);
    D = [];
    j = 1;
    for i=1:length(sub),
        files{i} = dir( fullfile(sub{i},'*.xyz') );
        if length(files{i})==1
            D(j) = i; 
            files_s{j} = sub{i}; 
            j=j+1;
        end
    end
    

    varaible files_s returns the desire paths that contain those specific data types!

    The subdir function can be found at: http://www.mathworks.com/matlabcentral/fileexchange/1492-subdir--new-

提交回复
热议问题