This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

combine

Combine data from multiple datastores

Syntax

dsnew = combine(ds1,ds2,...,dsN)

Description

example

dsnew = combine(ds1,ds2,...,dsN) combines two or more datastores by horizontally concatenating the data returned by the read function on the input datastores.

Examples

collapse all

Create a datastore that maintains parity between the pair of images of the underlying datastores. For instance, create two separate image datastores, and then create a combined datastore representing the two underlying datastores.

Create a datastore imds1 representing a collection of three images.

imds1 = imageDatastore({'street1.jpg','street2.jpg','peppers.png'}); 

Create a second datastore imds2 by transforming the images of imds1 to grayscale images.

imds2 = transform(imds1,@(x) rgb2gray(x));

Create a combined datastore from imds1 and imds2.

imdsCombined = combine(imds1,imds2);

Read the first pair of images from the combined datastore. Each read operation on this combined datastore returns a pair of images represented by a 1-by-2 cell array.

dataOut = read(imdsCombined)
dataOut = 1x2 cell array
    {480x640x3 uint8}    {480x640 uint8}

Display the output of the first read from the combined datastore.

imshow(imtile(dataOut));

Input Arguments

collapse all

Datastores to combine, specified as two or more comma separated datastore objects. For a complete list of built-in datastores, see Select Datastore for File Format or Application. You can also specify custom datastores.

Output Arguments

collapse all

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

The dsnew object is a new datastore instance that is the horizontally concatenated result of a read operation on each of the underlying datastores.

Introduced in R2019a