how to import a lot of data files
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
aliaa madbouly
am 14 Sep. 2014
Kommentiert: Geoff Hayes
am 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 Kommentare
Akzeptierte Antwort
Geoff Hayes
am 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 Kommentare
Geoff Hayes
am 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!