Main Content

shuffle

Shuffle all data in datastore

Description

example

dsrand = shuffle(ds) returns a datastore object containing a random ordering of the data from ds.

Examples

collapse all

Create an ImageDatastore object imds. Shuffle the files to create a new datastore containing the same files in random order.

imds = imageDatastore(fullfile(matlabroot, 'toolbox', 'matlab', {'demos','imagesci'}),'LabelSource','foldernames','FileExtensions', {'.jpg', '.png', '.tif'})
imds = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\cloudCombined.jpg';
             ' ...\matlab\toolbox\matlab\demos\example.tif';
             ' ...\matlab\toolbox\matlab\demos\landOcean.jpg'
              ... and 5 more
             }
     Labels: [demos; demos; demos ... and 5 more categorical]
    ReadFcn: @readDatastoreImage

imdsrand = shuffle(imds)
imdsrand = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\street2.jpg';
             ' ...\matlab\toolbox\matlab\demos\landOcean.jpg';
             ' ...\matlab\toolbox\matlab\imagesci\corn.tif'
              ... and 5 more
             }
     Labels: [demos; demos; imagesci ... and 5 more categorical]
    ReadFcn: @readDatastoreImage

Input Arguments

collapse all

Input datastore, specified as a datastore object. The input datastore can be any datastore for which isShuffleable returns true (such as imageDatastore). The input datastore also can be a CombinedDatastore, SequentialDatastore, or TransformedDatastore for which all underlying datastores are shuffleable.

Output Arguments

collapse all

Output datastore, returned as a datastore object containing randomly ordered data from ds.

Extended Capabilities

Version History

Introduced in R2016a