How can I combine two text files having different columns in one file?
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ND
el 19 de Jun. de 2015
Comentada: ND
el 19 de Jun. de 2015
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 comentarios
Respuesta aceptada
Azzi Abdelmalek
el 19 de Jun. de 2015
a=dlmread('a.txt');
b=dlmread('b.txt');
c=[a,b];
dlmwrite('c.txt',c);
2 comentarios
Azzi Abdelmalek
el 19 de Jun. de 2015
Editada: Azzi Abdelmalek
el 19 de Jun. de 2015
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)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!