How to save data to existing text file with old data

4 Ansichten (letzte 30 Tage)
Oddineus
Oddineus am 13 Apr. 2019
Kommentiert: Adam Danz am 30 Sep. 2019
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 Kommentare
Lucie S.
Lucie S. am 30 Sep. 2019
Bearbeitet: Lucie S. am 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
Adam Danz am 30 Sep. 2019
In that case, I think Fangjun Jiang has given you the best advice in the answer below.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Fangjun Jiang
Fangjun Jiang am 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().

Kategorien

Mehr zu Data Import and Export finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by