Main Content

shuffle

Shuffle files in datastore

Description

shuffledADS = shuffle(ADS) creates a deep copy of the input datastore, ADS, and shuffles the files using randperm.

Examples

collapse all

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

ADS = audioDatastore(fullfile(matlabroot,'toolbox','audio','samples'))
ADS = 
  audioDatastore with properties:

                       Files: {
                              ' .../matlab/toolbox/audio/samples/Ambiance-16-44p1-mono-12secs.wav';
                              ' .../matlab/toolbox/audio/samples/AudioArray-16-16-4channels-20secs.wav';
                              ' .../toolbox/audio/samples/ChurchImpulseResponse-16-44p1-mono-5secs.wav'
                               ... and 36 more
                              }
                     Folders: {
                              ' .../Bdoc24b.2725827/build/runnable/matlab/toolbox/audio/samples'
                              }
    AlternateFileSystemRoots: {}
              OutputDataType: 'double'
           OutputEnvironment: 'cpu'
                      Labels: {}
      SupportedOutputFormats: ["wav"    "flac"    "ogg"    "opus"    "mp3"    "mp4"    "m4a"]
         DefaultOutputFormat: "wav"

ADSshuffled = shuffle(ADS)
ADSshuffled = 
  audioDatastore with properties:

                       Files: {
                              ' .../matlab/toolbox/audio/samples/TrainWhistle-16-44p1-mono-9secs.wav';
                              ' .../runnable/matlab/toolbox/audio/samples/Rainbow-16-8-mono-114secs.wav';
                              ' .../runnable/matlab/toolbox/audio/samples/Turbine-16-44p1-mono-22secs.wav'
                               ... and 36 more
                              }
                     Folders: {
                              ' .../Bdoc24b.2725827/build/runnable/matlab/toolbox/audio/samples'
                              }
    AlternateFileSystemRoots: {}
              OutputDataType: 'double'
           OutputEnvironment: 'cpu'
                      Labels: {}
      SupportedOutputFormats: ["wav"    "flac"    "ogg"    "opus"    "mp3"    "mp4"    "m4a"]
         DefaultOutputFormat: "wav"

Input Arguments

collapse all

Input audio datastore, specified as an audioDatastore object.

Output Arguments

collapse all

Shuffled audio datastore, returned as an audioDatastore object containing randomly ordered files from ADS.

Version History

Introduced in R2018b