combine
Combine data from multiple datastores
Description
combines two or more datastores by horizontally concatenating the data returned by
ADSnew
= combine(ADS1,ADS2,...,ADSN
)read
of the input datastores.
Examples
Combine Datastores
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.
figure(1) spectrogram(dataOut{1},hamming(512),256,512,infoOut{1}.SampleRate,'yaxis') title('Original Data')
figure(2) idx = size(dataOut,2)/2+1; spectrogram(dataOut{2},hamming(512),256,512,infoOut{2}.SampleRate,'yaxis') title('Noised Data')
Input Arguments
ADS1,ADS2,...,ADSN
— Audio datastores to combine
audioDatastore
objects
Audio datastores to combine, specified as two or more comma separated audioDatastore
objects.
Output Arguments
ADSnew
— New audio datastore with combined data
audioDatastore
object
New audio datastore with combined data, returned as a
matlab.io.datastore.CombinedDatastore
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
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)