Error using fprintf in fopen

2 visualizaciones (últimos 30 días)
Surabhi
Surabhi el 3 de Mzo. de 2014
Respondida: Jos (10584) el 3 de Mzo. de 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

Respuestas (1)

Jos (10584)
Jos (10584) el 3 de Mzo. de 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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by