Reset the file-set object
reset( resets the file-set object
fs to the state where no file has been read from it. Resetting
enables rereading from the same file-set object.
Create a file-set object, get file information from the file-set object, and then reset the file-set object to its original state.
Create a file-set object for all the
.mat files in the
folder = fullfile(matlabroot,'toolbox','matlab','demos'); fs = matlab.io.datastore.DsFileSet(folder,... 'IncludeSubfolders',true,... 'FileExtensions','.mat');
While there are files in the file-set object, get the file information one file at a time.
while hasfile(fs) file = nextfile(fs); end
nextfile operation changes the position pointer in the
file-set object. To get the information on the first file, you must first
reset the file-set
reset(fs); fTable1 = nextfile(fs); % first file information