How to save data to existing text file with old data

4 次查看(过去 30 天)
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 个评论
Lucie S.
Lucie S. 2019-9-30
编辑:Lucie S. 2019-9-30
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
Adam Danz 2019-9-30
In that case, I think Fangjun Jiang has given you the best advice in the answer below.

请先登录,再进行评论。

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2019-9-27
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().

类别

Help CenterFile Exchange 中查找有关 Data Import and Export 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by