%Loop over all samples in the database %The name of the directory with the database dirname = 'D:\database_directory\'; %The suffix with the file format suffix = '.png'; %Open the file with the file names. fid=fopen([dirname 'listnames_MEW2012.txt'],'rt'); if(fid==-1) error(sprintf('Opening of file "%s" was not successful\n',[dirname 'listnames_MEW2012.txt'])); return; end %The loop over the file names; they are stored to MATLAB cells ni=0; while ~feof(fid) ni=ni+1; sn=fgetl(fid); listnames{ni}=sn(1:findstr(sn,';')-1); listnum(ni)=sscanf(sn(findstr(sn,';')+1:length(sn)),'%d'); end fclose(fid); % listnames - list of species % listnum - list of the numbers of samples of individual species % ni - number of species %The loop over all files for ix=1:ni %loop over species for jx=1:listnum(ix) %loop over samples of one species %reading of an image file a=double(imread([dirname listnames{ix} int2str(jx) suffix])); %Add a processing of the matrix a. end end