美文网首页
MATLAB路径下文件遍历

MATLAB路径下文件遍历

作者: lucientlau | 来源:发表于2017-10-12 21:49 被阅读0次

Demo遍历输出路径下所有.csv文件的路径

clear all;
close all;
clc;
foldPath = 'F:\yourfoldname';
searchFoldStr = strcat(foldPath,'\*.csv');
dirStruc = dir(searchFoldStr);
dirCell = struct2cell(dirStruc);
fileTotal = size(dirCell,1);
for fileIndex = 1:fileTotal
    filepath = cell2mat(strcat(foldPath,dirCell(1,fileIndex)));
% or filepath = strcat(foldpath,cell2mat(dirCell(1,fileIndex)));
    disp filepath;
end

Another method

foldPath = 'F:\yourfoldname';  % fold path
searchFoldStr = strcat(foldPath,'\*.csv');
dirStruc = dir(searchFoldStr);
for fileIndex = 1:fileTotal
    filepath = strcat(foldPath,dirStruc(fileIndex).name);
    disp filepath;
end

相关文章

网友评论

      本文标题:MATLAB路径下文件遍历

      本文链接:https://www.haomeiwen.com/subject/ugtayxtx.html