The reason for the error messages is because the number of files that are open exceeds the limit on the maximum number of files that can be kept open. There are several potential causes of this.
1) Make sure that, for every file you open with FOPEN, you close the file with a FCLOSE command when you are done using it.
Otherwise it is easy to quickly exceed the maximum number of open files. For example,
for i = 1:1000
if fopen([num2str(i) '.mat'],'a') == -1
break
end
end
i
load('1.mat')
fclose('all');
>> too_many_open_files_script.m
i =
457
Too many open files. Close files to prevent MATLAB instability.
Caused by:
Message Catalog MATLAB:load was not loaded from the file. Please check file location, format or contents
Note that you may get a different number of maximum files.
2) While MATLAB does not have a limit on the maximum number of files that can be open, the operating system does. Consult your system administrator for information on how to change this limit.
3) Another possible scenario is that you have too many open connections on a network file server. If you are reading and writing files on a network file system, that file system or file server may have limits on file connections. Consult your system administrator for information on how to change this limit.
Best Answer