helo guys
I generated a table , wrote in a txt file, and when I run again my code I will choose other file, it will write a new table... I want add this table in that same txt file which was the information of first table.
I did this at the end of program;
fid=fopen('dataFULL.txt','a+');
writetable(T,'dataFULL.txt','Delimiter',',');
fclose(fid);
when I run my code twice in order to choose other file... it is rewriting my txt file and doesn't save the previous data :((((((((((
Guys... any idea how can I do this?

 채택된 답변

dpb
dpb 2015년 7월 1일

0 개 추천

" If filename is the name of an existing text file, then writetable overwrites the file."
You can't with it. Since writetable opens the file using the file name and doesn't accept a file handle, the fopen in your code snippet above is totally ineffective; the two have nothing whatever in common with each other as far as what is written to the file; there are instead two totally independent file handles created/destroyed, the one explicitly is never used for anything.
Again as another question just a minute ago, seems like a reasonable enhancement request would be in order.

댓글 수: 2

Adriele Rocha
Adriele Rocha 2015년 7월 1일
you are right !!!Thanks
...The way of do that is just with fprintf, but fprintf doesn't accept cells as input. But I figured out a way :)
dpb
dpb 2015년 7월 2일
"_fprintf doesn't accept cells..."_
Yes, you must cast to char() or "use the curlies, Luke" to dereference the cell content to the underlying array values or strings.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기

질문:

2015년 7월 1일

댓글:

dpb
2015년 7월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by