I need to read about 4000 data files, each about 400 kB. The data will be analysed later so I wrote the files into a data structure. The importing operation takes about 4 mins and I have tried importdata
and dlmread
too but there is not much difference.
Please let me know if it is the loop, the import function or Matlab is simply slow at importing multiple large files. catch
/try
is used because some of these files can't be read properly but it doesn't seem to be slowing the script down.
Here's the script:
for k=40020:10:75000
try
name=['tmp' sprintf('%d',k)];
c=c+1;
m(k).count=k;
m(k).col=load(name);
[val in]=find(m(k).col(:,5)~=1);
m(k).id=m(k).col(val,1);
m(k).posx=m(k).col(val,2);
m(k).posy=m(k).col(val,3);
m(k).posz=m(k).col(val,4);
catch
disp(['Error'])
end
end