Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Adding Data to an existing file with matlab

Status
Not open for further replies.

epeus

Aerospace
Dec 20, 2003
15
0
0
AU
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.

 
Replies continue below

Recommended for you

smesajar,

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:-


cheerio
 
Status
Not open for further replies.
Back
Top