how to import a lot of data files
1 view (last 30 days)
Show older comments
aliaa madbouly
on 14 Sep 2014
Commented: Geoff Hayes
on 15 Sep 2014
hello i want to import to matlab a lot of data files with one line to write on MatLab instead of that all line.
- load aae20100101dmin.min
- load aae20100102dmin.min
- load aae20100103dmin.min
- load aae20100104dmin.min
- load aae20100105dmin.min
- load aae20100106dmin.min
- load aae20100107dmin.min
- load aae20100108dmin.min
- load aae20100109dmin.min
- load aae20100110dmin.min
- load aae20100111dmin.min
- load aae20100112dmin.min
- load aae20100113dmin.min
- load aae20100114dmin.min
- load aae20100115dmin.min
- load aae20100116dmin.min
- load aae20100117dmin.min
- load aae20100118dmin.min
- load aae20100119dmin.min
- load aae20100120dmin.min
- load aae20100121dmin.min
0 Comments
Accepted Answer
Geoff Hayes
on 15 Sep 2014
Aliaa - try the following
for k=1:21
filename = sprintf('aae201001%02ddmin.min',k);
load(filename);
end
The above code builds the filename on each iteration of the loop, and then loads the file.
2 Comments
Geoff Hayes
on 15 Sep 2014
sprintf('aae201001%02ddmin.min',k);
The %02d% indicates that the integer that will be inserted into the string should be padded with up to two zeros.
As for what you wish, creating separate local variables for each file read in, I don't recommend that. Instead, I think that you should just store all of this data into a matrix or cell array (if the fourth column of each loaded matrix has a different number of elements)
% store the data in a cell array
numFiles = 31;
data = cell(numFiles,1);
for k=1:numFiles
filename = sprintf('aae201001%02ddmin.min',k);
S = load(filename);
data{k} = S(:,4);
end
More Answers (0)
See Also
Categories
Find more on Whos 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!