From: Samiran on
Hi,

Below is the code I am trying out:

path='/home/sdam/netlist';
fid=fopen(path,'r');
fgets(fid);

But I got the error saying:

??? Error using ==> fgets
Invalid file identifier. Use fopen to generate a valid file identifier.

I didn't understand why this error came up even though I used fopen to generate the file identifier - fid.

Please help!

Regards
Sam
From: Walter Roberson on
Samiran wrote:
> Hi,
>
> Below is the code I am trying out:
>
> path='/home/sdam/netlist';
> fid=fopen(path,'r');
> fgets(fid);
>
> But I got the error saying:
>
> ??? Error using ==> fgets
> Invalid file identifier. Use fopen to generate a valid file identifier.
>
> I didn't understand why this error came up even though I used fopen to generate the file identifier - fid.

You failed to check that fid was not -1, indicating an error in opening
the file. Double check that that path exists and is not a directory.
From: Samiran on
Yes you are right. The path was not properly set. I should have been more careful in checking the error before I posted the problem. Thanks again...

Regards
Sam