How can I combine two text files having different columns in one file?
2 次查看(过去 30 天)
显示 更早的评论
I have two text files need to be combined to one.
a.txt b.txt
1 2 4
4 3 6
i need like this
c.txt
1 2 4
4 3 6
0 个评论
采纳的回答
Azzi Abdelmalek
2015-6-19
a=dlmread('a.txt');
b=dlmread('b.txt');
c=[a,b];
dlmwrite('c.txt',c);
2 个评论
Azzi Abdelmalek
2015-6-19
编辑:Azzi Abdelmalek
2015-6-19
a=dlmread('a.txt')
b=dlmread('b.txt')
header=' x y z'
c=[a b]
fid=fopen('file.txt','w')
fprintf(fid,'%s \r\n',header)
myformat='%12.8f %12.8f %12.8f \r\n'
fprintf(fid,myformat,c)
fclose(fid)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!