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 example signals 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 =

  0x0 empty char array


ans =

  0x0 empty char array


ans =

  0x0 empty char array


ans =

  0x0 empty char array


ans =

  0x0 empty char array


ans =

  0x0 empty char array


ans =

  0x0 empty char array


ans =

  0x0 empty char array


ans =

  0x0 empty char array


ans =

  0x0 empty char array

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:{                             }
    AlternateFileSystemRoots: [0x0 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