Main Content


Combine data from multiple datastores



ADSnew = combine(ADS1,ADS2,...,ADSN) combines two or more datastores by horizontally concatenating the data returned by read of the input datastores.


collapse all

Create a datastore that maintains parity between the audio of the underlying datastores. Create two separate audio datastores, and then create a combined datastore representing the two underlying datastores.

Create a datastore ads1 that points to the audio files included with Audio Toolbox.

folder = fullfile(matlabroot,'toolbox','audio','samples');
ads1 = audioDatastore(folder);

Create a second datastore ads2 by adding noise to the audio in the ads1.

ads2 = transform(ads1,@(x) x + 0.01*randn(size(x)) );

Create a combined datastore from ads1 and ads2.

adsCombined = combine(ads1,ads2);

Read the first pair of audio files from the combined datastore. Each read operation on this combined datastore returns a pair of audio signals in a 1-by-2 cell array and a pair of info structs in a 1-by-2 cell array.

[dataOut,infoOut] = read(adsCombined)
dataOut=1×2 cell array
    {539648x1 double}    {539648x1 double}

infoOut=1×2 cell array
    {1x1 struct}    {1x1 struct}

Plot the spectrograms of the first channels from both audio signals.

title('Original Data')

idx = size(dataOut,2)/2+1;
title('Noised Data')

Input Arguments

collapse all

Audio datastores to combine, specified as two or more comma separated audioDatastore objects.

Output Arguments

collapse all

New audio datastore with combined data, returned as a object.

Calling read on the combined datastore returns a cell array containing the output of calling read on the individual datastores.

Version History

Introduced in R2019a