MATLAB: Import multiple .text matrices in array

arraysdata importmatrices

I have a set of multiple (hundreds) matrix in .text format, and I need to import them in MATLAB for different kind of analysis.
Because the steps I need to take are the same foreach matrix, I would like to save all of them in an array, in order to use for loops in a function.
At the moment I'm only able to import each of them in the workspace individually doing:
files = dir('*.txt');
for i=1:length(files)
eval(['load ' files(i).name ' -ascii']);
end
In this way I only obtain hundreds of matrices with different names in the workspace, which is very bad to work with.
What is the best way to import the matrices and directly put them inside an array?

Best Answer

Do you have experience working with structures? In your workspace there will be only one item, which makes keeping the overview much easier.
for i=1:length(files)
YourStructure(i).matrix=load(files(i).name,'-ascii');
YourStructure(i).name=files(i).name
end
YourStructure(3).matrix %<-- you call it this way, where the indexing is now in the structure. This particular case it will call the 3rd entry in the structure.