필터 지우기
필터 지우기

importdata headerline concatenate files

조회 수: 1 (최근 30일)
Momo
Momo 2012년 12월 18일
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,

답변 (0개)

카테고리

Help CenterFile 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!

Translated by