File in use error, fclose not enough?

Hello,
I have the following problem. My plan was to write a txt file in matlab. This file contains the data to open in another program for controlling a robot.
fid = fopen('filename','wt');
for (i=1:amount)
fprintf(fid, '%s\n',my_cell{i});
end
fclose(fid)
When I run the file I want to be able to open the file in that other program. But it says 'file in use'. Is there a way to avoid this? Apparently fclose(fid) is not enough..
Thanks!

댓글 수: 1

Walter Roberson
Walter Roberson 2014년 5월 13일
Is it possible that you had fopen()'d it without fclose() in a run that error'd? If so then it would still be open. Have you tried exiting MATLAB and then trying?

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

답변 (2개)

Star Strider
Star Strider 2014년 5월 13일

1 개 추천

If this wouldn’t interfere with other file operations you’re doing:
fclose('all')
might work.
Wim
Wim 2014년 5월 13일

0 개 추천

Oh! thanks a lot! It seems like that was the problem, should've tried that myself!

카테고리

도움말 센터File Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

질문:

Wim
2014년 5월 13일

답변:

2014년 5월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by