Integrating several text files
显示 更早的评论
Hello
I have several text files which each of them contains thousands of numbers in 2 columns. I want to integrate them all into one file with the same formate, starting from the first row of the first file and ending with the last row of the last file.
回答(1 个)
David Hill
2020-12-3
Just read them in and concatenate.
b=[];
for n=1:numberoffiles
fileName=sprintf('yourfile%d',n);%assuming file names are numbered
a=readmatrix(fileName);
b=[b;a];%concatenate
end
5 个评论
Morteza Tohidi
2020-12-3
Walter Roberson
2020-12-3
If they are not numbered, then which order do they need to be read in? For your purposes, is it okay if the data is put together in any "convenient" order, or does the name of the file influence the order it has to be placed in relative to the other files?
Morteza Tohidi
2020-12-3
编辑:Morteza Tohidi
2020-12-3
Rik
2020-12-3
If you have a way to order them, you can read them in that order. Are you storing the file names in a struct or a cell?
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!