How to iterate through several files
Show older comments
I have several data files, data0.txt, data1.txt, etc. that contain numbers separated by spaces. I would like to iterate through each of these files and run some calculations:
file_strs = {'D:\Data\data0.txt' 'D:\Data\data1.txt' 'D:\Data\data2.txt'};
for a = 1:length(file_strs)
T1=importdata(file_strs(a), ' ');
% Do some calculations
......
end;
However, when I try this, I get:
Error using importdata (line 137)
Unable to open file.
Error in test (line 20)
T1=importdata(file_strs(a), ' ');
What am I doing wrong?
Steve
Accepted Answer
More Answers (0)
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!