importdata headerline concatenate files
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, this is a continuation to my question: concatenate and replace comma by dot. Well, I have a series of 300 files with names respectively from data-1.dat to data300.dat. Each file consist of 6 columns and 25 rows and a headerline (files contain scalars with comma instead of dot, ex: 3,21223232) I want to concatenate all files into one matrix and I'm using the code below:
% code
numfiles = 300;
concat= cell(1, numfiles);
for i=1:300;
i
filename = sprintf(data-%d.dat, i);
concat{i} = importdata(filename, '\t');
end
newFile = fullfile(tempdir, 'JoinedFile.dat');
FID = fopen(newFile, 'w');
if FID == -1, error('Cannot open file for writing'); end
fprintf(FID, '%s', concat{:});
fclose(FID);
Then I import the file "JoinedFile.dat" but I'm struggling with the headerline, when I use the code below:
all_data= importdata('JoinedFile.dat');
It imports data in a string with text, colheader and data but only the first set of 25 rows and 6 columns (it means that it doesn't read the next headerline) and leave 299 sets.
Best regards,
댓글 수: 1
Jan
2012년 12월 20일
I've answered this in your former question http://www.mathworks.com/matlabcentral/answers/56828-concatenate-and-replace-comma-by-dot already.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!