How to merge two files into one text file?

跟風遠走 提交于 2019-12-02 11:59:05

I don't think there is a matlab way of doing it easily. But you can use system commands:

Windows:

system(type a.txt b.txt >ab.txt)

Linux:

system(cat a.txt b.txt >ab.txt)

Dont forget to put the path in the files if they are not in your current directory! This works:

fin=fopen('D:\box1.txt','wt');
fprintf(fin,'   Hello \n');
fclose(fin)

fin=fopen('D:\box2.txt','wt');
fprintf(fin,'welcome \n');
fclose(fin)

system('type D:\box1.txt D:\box2.txt >E:\box12.txt')
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!