Loop Through Loading Files Error

1 次查看(过去 30 天)
Greg B.
Greg B. 2015-6-10
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 个)

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by