Loop Through Loading Files Error
1 次查看(过去 30 天)
显示 更早的评论
Hi there.
I have a question about how to load in data from multiple directories, but the files I need to load all have the same name. Here's what I have thus far:
smoothlist1 = dir('smooth*');
for i = 1:numel(smoothlist1) % loop through smooth directories
path2 = sprintf('%s%s/Curves',path1,smoothlist1(i).name);
cd(path2); % change directories into Curves directory, where results.xy file is located.
data = load('results.xy');
end
I loop through each directory in a list I call
'smoothlist1'. Within each 'smoothlist1 directory, I change directories into ~/smoothlist1/Curves/. Within this directory, there is a file called results.xy. I need to load each of the results.xy file from each ~smoothlist1/Curves directory, but i am unsure how to do that. What I have above just loads in the final results.xy file in the last smoothlist1/Curves/ directory.
So the question is, how do I loop through loading in that results.xy file from multiple directories? I have tried doing data(j) = results.xy, where I add a counter for j, but that did not work. I would like to load these results.xy files into separate filenames as well.
Thank you for your help.
G
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!