Main Content

shuffle

Shuffle signals in signal datastore

Since R2020a

Description

example

shuffledsds = shuffle(sds) creates a Deep Copy of the input datastore sds and shuffles the signals using the randperm function.

Examples

collapse all

Specify the path to the example signals included with MATLAB®. Create a signal datastore that points to the specified folder and display the names of the files in the datastore.

folder = fullfile(matlabroot,'toolbox','matlab','audiovideo');
sds = signalDatastore(folder);
[~,c1] = fileparts(sds.Files)
c1 = 7x1 cell
    {'chirp'   }
    {'gong'    }
    {'handel'  }
    {'laughter'}
    {'mtlb'    }
    {'splat'   }
    {'train'   }

Shuffle the files to create a new datastore containing the same files in random order. Display the names of the files in the shuffled datastore.

sdsshuffled = shuffle(sds);
[~,c2] = fileparts(sdsshuffled.Files)
c2 = 7x1 cell
    {'splat'   }
    {'handel'  }
    {'train'   }
    {'mtlb'    }
    {'chirp'   }
    {'gong'    }
    {'laughter'}

Input Arguments

collapse all

Signal datastore, specified as a signalDatastore object.

Output Arguments

collapse all

Shuffled signal datastore, returned as a signalDatastore object containing randomly ordered files or members from sds.

More About

collapse all

Deep Copy

A deep copy refers to a copy in which all levels of data are copied. For example, a deep copy of a structure copies each field and the contents of each field, if any.

Version History

Introduced in R2020a