matlab.io.datastore.DsFileSet.hasfile - Determine if more files are available in file-set object - MATLAB (original) (raw)

Main Content

Class: matlab.io.datastore.DsFileSet
Namespace: matlab.io.datastore

Determine if more files are available in file-set object

Description

tf = hasfile([fs](#d126e443175)) returns logical1 (true) if any more files are available to process in the DsFileSet object specified by fs. Otherwise, it returns logical 0 (false).

Input Arguments

expand all

fs — Input file set

matlab.io.datastore.DsFileSet object

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

Example: hasfile(fs)

Examples

Check if File-set Object has More Files

Create a file-set object, check if the file-set object has any files, and then read the data iteratively.

Create a file-set object for all the .mat files in thedemos folder.

folder = fullfile(matlabroot,'toolbox','matlab','demos'); fs = matlab.io.datastore.DsFileSet(folder,... 'IncludeSubfolders',true,... 'FileExtensions','.mat');

Use the hasfile method to check if the file-set object has more files to read. Get the file information, one file at a time, while files remain in the file-set object.

while hasfile(fs) file = nextfile(fs); end

Version History

Introduced in R2017b