preview - Preview subset of data in datastore - MATLAB (original) (raw)
Main Content
Preview subset of data in datastore
Syntax
Description
[data](#budueym-1-data) = preview([ds](#budueym-1-ds))
returns a subset of data from datastore ds
without changing its current position.
Examples
Preview Data in TabularTextDatastore
Create a datastore from the sample file, airlinesmall_subset.csv
, which contains tabular data.
ds = tabularTextDatastore("airlinesmall_subset.csv","TreatAsMissing","NA",... "MissingValue",0);
Modify the SelectedVariableNames
property to specify the variables of interest.
ds.SelectedVariableNames = ["DepTime","ArrTime","ActualElapsedTime"];
Preview the data for the selected variables.
data=8×3 table DepTime ArrTime ActualElapsedTime _______ _______ _________________
2117 2305 108
1252 1511 79
1441 1708 87
2258 2336 38
1814 1901 47
1822 1934 72
729 841 72
1704 1829 85
Preview Data in KeyValueDatastore
Create a datastore from the sample file, mapredout.mat
, which is the output file of the mapreduce
function.
ds = datastore('mapredout.mat');
Preview the data in the datastore.
data=1×2 table
Key Value
______ _________
{'AA'} {[14930]}
Preview Data in CombinedDatastore
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 an image 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 and then reflecting the images horizontally.
imds2 = transform(imds1,@(x) fliplr(im2gray(x)));
Create a combined datastore from imds1
and imds2
.
imdsCombined = combine(imds1,imds2);
Preview the data in the combined datastore. The output is a 1-by-2 cell array. The two columns represent the first subset of data from the two underlying datastores imds1
and imds2
, respectively.
dataOut = preview(imdsCombined)
dataOut=1×2 cell array {480x640x3 uint8} {480x640 uint8}
Display the previewed data as a pair of tiled images.
tile = imtile(dataOut); imshow(tile)
Output Arguments
data
— Subset of data
table | array
Subset of data, returned as a table or an array depending on the type ofds
.
Type of Datastore | Data type of data | Description |
---|---|---|
TabularTextDatastore andSpreadsheetDatastore | Table | Table with variables specified by theSelectedVariableNames property. The table contains at most eight rows. |
ImageDatastore | Integer array | Array of integers corresponding to the first image. The dimensions of the integer array depend on the type of image: For grayscale images,data is m-by-n. For truecolor images,data is m-by-n-by-3. For CMYK Tiff images,data is m-by-n-by-4. The preview function supports all image types supported by theimread function. For more information on the supported image types, see imread. |
KeyValueDatastore | Table | Table with the variables Key andValue. |
FileDatastore | Table | Table containing the output returned by the read function, specified by the 'ReadFcn' parameter in the fileDatastore function. |
TransformedDatastore | Varies | The output is the same as the output returned by the underlying datastore specified by theUnderlyingDatastores property. For example, if the underlying datastore is an image datastore with a ReadSize property value of 1, thendata is returned as an integer array. |
CombinedDatastore | Cell array | Each element of the cell array contains the output returned by the corresponding underlying datastore specified by the UnderlyingDatastores property. |
SequentialDatastore | Varies | The output is a small amount of data from the first nonempty underlying datastore. If all underlying datastores are empty, output is the empty type based on the first underlying datastore. If there are no underlying datastores, output is an empty double. |
Extended Capabilities
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
Usage notes and limitations:
- In a thread-based environment, you can use
preview
only with the following datastores:ImageDatastore
objectsCombinedDatastore
,SequentialDatastore
, orTransformedDatastore
objects you create fromImageDatastore
objects by usingcombine
ortransform
You can usepreview
with other datastores if you have Parallel Computing Toolbox™. To do so, run the function using a process-backed parallel pool instead of usingbackgroundPool
orThreadPool
(use eitherProcessPool
orClusterPool
).
For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced in R2014b