基本上,我有一组我想循环的文件夹,以便对这些文件夹中的文件执行大量分析。我编写了代码,以便为每个文件夹更改当前的措辞目录(cd)。这工作正常,但最后我遇到了问题。代码成功通过所有文件夹后,它将从第一个文件夹再次启动,并一次又一次地浏览所有文件夹。所以基本上我在这些文件夹中有无限循环。
这是我现在的基本代码。
parentfolder = pwd;
subjectfolder = dir(fullfile(parentfolder, '\'));
S = length(subjectfolder);
for s = 3 : S
foldername = subjectfolder(s).name;
%set path to the files within the current folder
path_to_data = pwd;
% a whole bunch of code for analysis is here
end
%make the path go up from the current open folder to the list of folders
to go to the next folder in the list
%not even sure if i need this because when i just ran it without cd./. it still
looped endlessly through the folders
cd./.
对于我能做什么有什么建议吗?
非常感谢你的帮助!