Fgetl error on script

Hello. I have a problem with fgetl function. Specifically i hace the following script...
....
fid=fopen(outfile,'r');
if fid<0
error('wrong output file name, Stamatame tin analysi')
end
nodeRes =[];
linkRes = [];
icntLine = 0;
while 1
icntLine=icntLine+1;
tline=fgetl(fid);
if ~ischar(tline), break, else i=i+1; end
....
When i press run button, code run successfully for the first repeat of loop. When icntLine=2 script fail with the message
Error using fgets
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in fgetl (line 34)
[tline,lt] = fgets(fid);
Error in main_prgtry (line 72)
tline=fgetl(fid);
if i run the fgetl from command window, it runs successfully... Can anybody help me? Thank you

1 件のコメント

Geoff Hayes
Geoff Hayes 2017 年 7 月 11 日
giannis - can you show us all of the code for the while block? Are you manipulating the fid anywhere else in the code?

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeAuthor Block Masks についてさらに検索

質問済み:

2017 年 7 月 11 日

コメント済み:

2017 年 7 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by