Main Content



Maximum number of partitions


N = maxpartitions(fs)


N = maxpartitions(fs) returns the maximum number of partitions for a given DsFileSet object fs.

Input Arguments

expand all

Input file-set, specified as a DsFileSet, FileSet, or BlockedFileSet object. To create a DsFileSet object, see To create a FileSet object, see To create a BlockedFileSet object, see

Output Arguments

expand all

Number of partitions, returned as an integer. The value of N depends on the FileSplitSize property of the DsFileSet object.

  • If FileSplitSize contains 'file', then maxpartitions sets N equal to the total number of files in fs.

  • If FileSplitSize contains a numeric value, then maxpartitions determines N as the sum of the ceil of the file sizes of each file divided by the FileSplitSize.


Get Maximum Number of Partitions for the File-Set Object

Create a file-set object and get the number of partitions for different values of the FileSplitSize property.

Create a file-set object for all .mat files in a folder and check the number of files.

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


The FileSplitSize property of the DSFileSet object is set to 'file'. Therefore, maxpartitions returns a value equal to the number of files.

ans =


Set the FileSplitSize property to a numeric size (2000 bytes) and compute maxpartitions.

fs =,...
n = maxpartitions(fs)
n =


Version History

Introduced in R2017b