필터 지우기
필터 지우기

How can I generate text file in loop?

조회 수: 3 (최근 30일)
siddhesh rane
siddhesh rane 2014년 4월 7일
답변: Alberto 2014년 4월 7일
I need to generate text file in MATLAB which will be edited in every loop. When I use fopen without using fclose MATLAB gives error. and if I use fclose file is overwritten in every iteration and only data from last iteration is stored.
  댓글 수: 2
Jan
Jan 2014년 4월 7일
Without seeing the code, we cannot guess, where the problem is. When you state, that you get an error, showing the code and posting a complete copy of the error message is the obligatory strategy to obtain help from the readers. So I suggest to edit the original question and provide the required information.
Ioannis
Ioannis 2014년 4월 7일
Suggestion, why don't you manipulate a .mat file, in which you can append data in each iteration, and then save the whole thing to .txt.

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

채택된 답변

Alberto
Alberto 2014년 4월 7일
You sould open the file with the 'append' modificator.
fid= fopen(filename, 'a')
% Use fprintf (for example) to print the stuff fprintf(fid, ...);
fclose(fid)
Also, you cant open an already opened file, or close a non opened file. Use try/catch to escape errors.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by