How to save data to existing text file with old data

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 comentarios

Lucie S.
Lucie S. el 27 de Sept. de 2019
Editada: Lucie S. el 27 de Sept. de 2019
Hi,
I have the same question. Did you find any solution to that? Thanks
Adam Danz
Adam Danz el 27 de Sept. de 2019
Editada: Adam Danz el 27 de Sept. de 2019
What function are you using to write the data to the file? Why not write to a csv file?
Lucie S.
Lucie S. el 30 de Sept. de 2019
Editada: Lucie S. el 30 de Sept. de 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
Adam Danz el 30 de Sept. de 2019
In that case, I think Fangjun Jiang has given you the best advice in the answer below.

Iniciar sesión para comentar.

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 27 de Sept. de 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().

Preguntada:

el 13 de Abr. de 2019

Comentada:

el 30 de Sept. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by