Contenido principal

partition

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

Partition file-set object

Description

subfs = partition(fs,n,index) partitions file set fs into the number of parts specified by n and returns the partition corresponding to the index index.

subfs = partition(fs,'Files',index) partitions the file set by files and returns the partition corresponding to the file of index index in the Files property. (FileSet object only) (since R2026a)

subfs = partition(fs,'Files',filename) partitions the file set by files and returns the partition corresponding to the file specified by filename. (FileSet object only) (since R2026a)

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.

Number of partitions, specified as a positive integer.

Example: 3

Data Types: double

Index, specified as a positive integer.

Example: 1

Data Types: double

File name, specified as a character vector or string scalar.

The value of filename must match exactly the file name contained in the Filename property of the matlab.io.datastore.FileInfo object. To ensure that the file names match exactly, specify filename using fs.FileInfo.Filename(N) where N is the index of the file in the Filename property. For example, fs.FileInfo.Filename(3) specifies the third file in the file set fs.

Example: fs.FileInfo.Filename(3)

Examples

Partition File-Set Object and Get One Partition

Create a file-set object, partition the file-set object, and get the files contained in a specified partition.

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

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

Partition the 40 files into five partitions and obtain the first partition. Then, get the file information of all files in the first partition.

subfsA = partition(fs,5,1) % first 8 files
subfsA_fileInfo = resolve(subfsA)

Obtain the second partition and files information for files in this partition.

subfsB = partition(fs,5,2) % next 8 files
subfsB_fileInfo = resolve(subfsB)

Tips

  • Use the NumFiles property of the DsFileSet object to find the number of files in fs and use that number to estimate a reasonable number of partitions for the datastore.

Version History

Introduced in R2017b

expand all