how to import a lot of data files
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Geoff Hayes
2014년 9월 15일
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
Geoff Hayes
2014년 9월 15일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!