Why fileID change every time I run the function?

I'm still a newbie to matlab. It occurs to me every time I run my function,fid changes. Does it matter that fid change?
I used fid = fopen('filename','rt') in paricular.
THis should appear very stupid to you all but I really have nobody to turn to. Thank you!

답변 (2개)

Star Strider
Star Strider 2016년 11월 13일

0 개 추천

You need to use the fclose function after you have finished reading the file. That closes the file and resets the fileID.
Steven Lord
Steven Lord 2016년 11월 14일

0 개 추천

The only specific value for the file ID that matters is -1. That means fopen encountered a problem trying to open the file.
Otherwise, you shouldn't depend on the specific value of the file ID, you should just use the output argument variable from a call to fopen with the other file I/O functions that accept file IDs.

카테고리

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

태그

질문:

2016년 11월 13일

답변:

2016년 11월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by