subset

Create datastore with subset of signals

Description

example

sdssubset = subset(sds,indices) returns a signal datastore sdssubset containing a subset of the signals in sds.

Examples

collapse all

Specify the file path to the examplesignal included with Signal Processing Toolbox™.

folder = fullfile(matlabroot,'toolbox','matlab','demos');

Create a signal datastore that points to the specified folder. List the names of the first ten files in the datastore.

sds = signalDatastore(folder);
c = extractAfter(sds.Files,'demos\');
c{1:10}
ans = 
'accidents.mat'
ans = 
'airfoil.mat'
ans = 
'airlineResults.mat'
ans = 
'cape.mat'
ans = 
'census.mat'
ans = 
'clown.mat'
ans = 
'detail.mat'
ans = 
'dmbanner.mat'
ans = 
'durer.mat'
ans = 
'earth.mat'

Create a logical vector indicating whether the file names in the signal datastore start with 'air'.

fileContainsAir = cellfun(@(c)startsWith(c,'air'),c);

Call the subset function on the signal datastore and the indices corresponding to the files starting with 'air'.

sdssubset = subset(sds,fileContainsAir)
sdssubset = 
  signalDatastore with properties:

                       Files:{
                             'B:\21\ubhattac.techreview.0111\matlab\toolbox\matlab\demos\airfoil.mat';
                             ' ...\matlab\toolbox\matlab\demos\airlineResults.mat'
                             }
    AlternateFileSystemRoots: [0×0 string]
                    ReadSize: 1

Input Arguments

collapse all

Signal datastore, specified as a signalDatastore object.

Specify indices as:

  • A vector containing the indices of files or members to be included in sdssubset. The subset function accepts nonunique indices.

  • A logical vector the same length as the number of files or members in sds. If indices are specified as a logical vector, true indicates that the corresponding files or members are to be included in sdssubset.

Data Types: double | logical

Output Arguments

collapse all

Subset of signal datastore, returned as a signalDatastore object.

Introduced in R2020a