Path: news.mathworks.com!not-for-mail
From: "Ben " <ben.cowley@helsinki.fi>
Newsgroups: comp.soft-sys.matlab
Subject: Compiled Matlab fgets error
Date: Tue, 11 Sep 2012 21:06:08 +0000 (UTC)
Organization: Helsingin Yliopiston Observatorio
Lines: 13
Message-ID: <k2o940$q1o$1@newscl01ah.mathworks.com>
Reply-To: "Ben " <ben.cowley@helsinki.fi>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1347397568 26680 172.30.248.47 (11 Sep 2012 21:06:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 11 Sep 2012 21:06:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3269771
Xref: news.mathworks.com comp.soft-sys.matlab:778273

I'm experiencing what seems like a common error - I have code which opens files and reads contents, but when I compile said code it throws an InvalidFid error:

"Error using fgets
Invalid file identifier. Use fopen to generate a valid file identifier.

Error in fgetl (line 34)
..."
and so on.

The problem for me is that my code uses Eeglab to open .gdf files and the fgets error is thrown from inside there. I cannot change that part of the code, so my question is, does the way that I set up the path in the code or compile the program affect its functioning?

FYI, the path is obtained using uigetfile(), and then before the line where the EEG data is read there are several types of text file being read without throwing this error. So that part of the program seems to work ok - it is only when the Eeglab code is called that it fails. 
Can anyone shed light on how the compiler affects calls to file read functions?