Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Data to an existing file with matlab

Status
Not open for further replies.

epeus

Aerospace
Joined
Dec 20, 2003
Messages
15
Location
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.

 
Hello:

Try this piece of code

Fid=fopen('path_and_name.ext','a');
fprintf(Fid,'What you want to add');
fclose(Fid);
 
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.

Part and Inventory Search

Sponsor

Back
Top