I'm running a long and complex program for data analysis that runs perfectly fine with certain numbered data files but not with others.
When it is unhappy, I get the following error: ??? Error using ==> textscan Invalid file identifier. Use fopen to generate a valid file identifier.
The file names are zs_120.dat and zs_149.dat. I see no reason why 120 is a valid file identifier but 149 is not?
Is there some kind of setting I can change, either in Matlab or on my computer, that will enable it to run properly?
I'm currently running windows 10, as is my coworker who can run the program. My computer is a HP Pavilion laptop. Matlab version is 7.11.0(R2010a)
EDIT: More information:
fopen documentation returns ans = -1
The second line of the error message is as follows: Error in ==> NonRephasingC16_120 at 51 MDdata(:,:) = textscan(file,'%s','delimiter', ['whitespace','\n'], 'BufSize', 8000);
here, NonRephasingC16_120 is the name of the program being used.
The files are also both in the same folder.
Check the second output ‘errmsg’ in your fopen (link) call. It will tell you what the problem is. Most likely, it cannot find the file. The reasons could be misspelling, the file is in a different directory, or any number of other possibilities.
[fileID,errmsg] = fopen( ... )
From the documentation:
The which function may also not be able to find them. It will return the full path and filename if it can:
result = which('zs_120.dat') result = which('zs_149.dat')