How to save data to existing text file with old data

조회 수: 2 (최근 30일)
Oddineus
Oddineus 2019년 4월 13일
댓글: Adam Danz 2019년 9월 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