Katerina - are you running the code from the directory where those files are located, or some other directory? Is the directory that contains the files in your MATLAB search path?
If a file is in a directory/folder that is in the MATLAB search path, then you will be able to open (or load) that file by simply providing the file name, as you are doing with
But if the directory/folder for this file is not in the MATLAB search path, then the code will not be able to find that file and you will see the
Error using load
Unable to read file 'AbR1997.txt': no such file or directory.
You can do a couple of things - either add the directory (that contains these files) to the MATLAB search path, or better, just specify where the file is located. If we assume that your directory is N:/My Documents/MATLAB/runfiles, then build the folder name as
foldername = fullfile('N:', 'My Documents', 'MATLAB','runfiles');
and use this when we build the file name
for n=1997:1999
filename = fullfile(foldername,['AbR', int2str(n), '.txt']);
ALL=load(filename)
end
Try the above and see what happens!
Best Answer