For example, if I have the file A.dat and B.datand
A.dat have
1 2 3
4 5 6
7 8 9
and the file B.dat is empty at first.
How can I (using Matlab functions) open the file B.dat print the A.dat content to it and print another entries like
10 11 12
13 14 15
?
I tried
fileA=fopen('A.dat','r')
fileB=fopen('B.dat','w');
fprintf(fileB,fileA);
or
fprintf(fileB,fscanf(fileA));
or
fprintf(fileB,fscanf(fileA,'%s'));
but none works.
You seem to be confused as to what the functions are used for.
fprintfandfscanfare probably not what you are looking for (but can be useful).Try using
freadandfwriteinstead:Check the documentation for file operations at http://www.mathworks.se/help/techdoc/ref/f16-5702.html#f16-14516