importdata headerline concatenate files

2 次查看(过去 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