"Teh " <email@example.com> wrote in message <firstname.lastname@example.org>... > Dear Users, > > I have saved all my .MAT files (24231 of them) using -v6 format. Hence, the saving part is very fast with less than 1s. > > When I load these files individually without loading them 1 by 1 using for loop, it takes less than 1s as well. > > The problem comes when I try to load these MAT files one by one in a loop manner. > for example > > for i = 1:24231 > load(num2str(i).mat); > end > > The first load at i = 1 is less than 1s, but from i = 2 onwards, the loading time becomes consistently slow at 7s. > > May I know why?
Possibly because each file load() needs to deallocate and reallocate memory for the same variables, or possibly because you're running out of physical memory and the OS is using virtual (swap) memory for allocating new data.