How to save data to existing text file with old data
4 views (last 30 days)
Show older comments
Hello.
I create a program using MATLAB, which will generate data every time i run it. and i want save these data as a table to existing text file with the old data. here is an example of the data:
"SubNum,LastName,Age,Gender,HIDS,GDT1,GDT2,GDT3,GDT4,GDT5,GDT6,GDTav
1,Jim,23,Male,NO,20,20,20,20,20,20,20,"
4 Comments
Lucie S.
on 30 Sep 2019
Edited: Lucie S.
on 30 Sep 2019
Hi Adam,
Thanks for your answer. To give some context. I've made a program of data processing that give a report at the end including tables (with titles on rows and lines) that I have created using the table function. I made the report in html using the publish function so I was using disp to display the table and the publish function was doing the job. But now I've made an application of that program using the app compiler. The app compiler doesn't allow me to use the publish function.... So I made a report in a txt file using fprintf for all the text I need to write and the only problem is to write the tables in that file without overwriting the file. I'd like to keep using the table function to create my tables if this is possible. The csv file doesn-t allow me to make a nice report.
Adam Danz
on 30 Sep 2019
Answers (1)
Fangjun Jiang
on 27 Sep 2019
I guess the key point is to use fid=fopen('FileName','a+t'), open or create file for reading and writing; append data to end of file. See help for fopen().
0 Comments
See Also
Categories
Find more on Data Import and Export in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!