0

I am trying to merge two text output file into one text file .

file 1:

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

file 2:

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

Any thoughts?

marsei
  • 7,691
  • 3
  • 32
  • 41
mecaeng
  • 93
  • 2
  • 8
  • @Prætorian how to merge 2 files into one text file ?? but it works with Mac way . if you have alternative one ,that will great – mecaeng Apr 18 '12 at 23:16

1 Answers1

5

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')
Mac
  • 3,397
  • 3
  • 33
  • 58