I have a MATLAB script that I could swear worked fine the last time I used it (a year ago). Now I get this error:
Invalid file identifier. Use fopen to generate a valid file identifier.
If I understand correctly, it cannot find or open (?) The file specified elsewhere in the script. It is right? If so, what can cause this?
fid ( ) - fopen. , . fopen, fid. , fid ( ) -, , fread, fscanf fclose. fopen fid of -1. fopen fid, 3 .
fid
fopen
fread
fscanf
fclose
-1
3
- , . MATLAB fopen ( ) fclose , fid ( ) ( ) fopen fclose.
, fopen. http://www.mathworks.se/help/matlab/ref/fopen.html, fopen:
fileID = fopen(filename,permission)
, : 'r' ( ) | 'w' | 'a' | 'r +' | 'w +' | 'a +' |...
'r' - .
'w' - . , .
'a' - . .
'r +' - .
'w +' - . , .
'a +' - . .
...
fopen , "r" ( ), fopen -1, . :
fid=fopen('tmp.txt', 'w'); fid=fopen('tmp.txt', 'a');
. , , , ( ). , , . !
, .
ASF. Matlab ( ), , .
fopen , MATLAB / .
, /MATLAB ( ).
fopen . , MATLAB admin, .
, excel, fopen -1. , .
.
filename = '/data/myfile.txt';
,
filename = 'data/myfile.txt';
This also happens when trying to create a file in a non-existent directory. Try it mkdir('folderName')in MATLAB or just create a directory in advance.
mkdir('folderName')
This also happens when a script tries to read outside the file.