Main Content

reset

Class: matlab.io.datastore.DsFileSet
Namespace: 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, specified as a DsFileSet, FileSet, or BlockedFileSet object. To create a DsFileSet object, see matlab.io.datastore.DsFileSet. To create a FileSet object, see matlab.io.datastore.FileSet. To create a BlockedFileSet object, see matlab.io.datastore.BlockedFileSet.

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

Version History

Introduced in R2017b