Error using fprintf in fopen

Hi everybody,
I am getting the following error:
Error using fprintf Invalid file identifier. Use fopen to generate a valid file identifier.
Error in LATEST (line 2) fprintf(fid,' Lam Efficiency\n');
while I am ting to execute the following:
fid=fopen('latest.txt','wt'); fprintf(fid,' Lam Efficiency\n');
latest.txt is a text file that I have already created.
Please help

답변 (1개)

Jos (10584)
Jos (10584) 2014년 3월 3일

0 개 추천

Always check the value of fid after a call to fopen to see if it is valid:
[fid, message] = fopen('latest.txt','wt') ;
if fid == -1,
disp(message)
else
fprintf ...
fclose(fid)
end

카테고리

도움말 센터File Exchange에서 Standard File Formats에 대해 자세히 알아보기

태그

질문:

2014년 3월 3일

답변:

2014년 3월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by