Error using fprintf in fopen

2 ビュー (過去 30 日間)
Surabhi
Surabhi 2014 年 3 月 3 日
回答済み: Jos (10584) 2014 年 3 月 3 日
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 日
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

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by