我有一个关于.txt
在同一时间和同一脚本中读取多个文件的问题。我有一个主文件夹Matlab
,其中有 7 个子文件夹Folder1 to Folder 7
,其中有 un document file.txt
。
我想在当前文件夹中运行的脚本中读取每个“file.txt” Matlab
。有没有快速的方法来做到这一点?还是我被迫load file.txt
为每个文件夹做。
您可以使用dir
来列出您的所有文件夹。然后,您可以为每个文件夹创建文件路径并加载此文件。
folder = dir('Folder*'); %list all the folder whose name start with 'Folder'
for ii = 1:length(folder)
s{ii} = fullfile(folder(ii).name,'text.txt'); %create the path for each file
load(s{ii});
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句