reset

Class: matlab.io.datastore.DsFileSet
Package: matlab.io.datastore

Reset the file-set object

Syntax

reset(fs)

Description

reset(fs) 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.

Input Arguments

expand all

Input file-set object, specified as a matlab.io.datastore.DsFileSet object. To create a DsFileSet object, see matlab.io.datastore.DsFileSet.

Examples

Reset 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 demos folder.

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

The 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 object.

reset(fs);
fTable1 = nextfile(fs); % first file information

Introduced in R2017b