Adding Data to an existing file with matlab
Adding Data to an existing file with matlab
(OP)
anyone know how to add data to an existing data file.
ie, i have a data file and i want to add a new line of data (matrices) to the file.
i have looked at the save -append option but that overwrites existing variables and can only be used on .mat files (i think), i am using .dat files.
basically everytime i run my script i want it add a new line of data to my results data file.
hope someone else has worked this out!!
any help is greatly appreciated.
ie, i have a data file and i want to add a new line of data (matrices) to the file.
i have looked at the save -append option but that overwrites existing variables and can only be used on .mat files (i think), i am using .dat files.
basically everytime i run my script i want it add a new line of data to my results data file.
hope someone else has worked this out!!
any help is greatly appreciated.





RE: Adding Data to an existing file with matlab
Try this piece of code
Fid=fopen('path_and_name.ext','a');
fprintf(Fid,'What you want to add');
fclose(Fid);
RE: Adding Data to an existing file with matlab
yes thats right...after a bit of research i came up with this:
note the 'a+' - to append to the existing file
fid = fopen('file.txt','a+');
fprintf(fid,'\n');
fprintf(fid,'%9.4f',var1,var2,var3);
fclose(fid);
fprintf is very powerful function - can generated very nicely formatted data files!
for more info on fprintf see:-
http://www.mathworks.com/access/helpdesk/help/techdoc/r...
cheerio