Error using fprintf in fopen

2 Ansichten (letzte 30 Tage)
Surabhi
Surabhi am 3 Mär. 2014
Beantwortet: Jos (10584) am 3 Mär. 2014
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

Antworten (1)

Jos (10584)
Jos (10584) am 3 Mär. 2014
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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by