Main Content

subset

Create datastore with subset of signals

Since R2020a

Description

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

example

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] = fileparts(sds.Files(1:10))
c = 10x1 cell
    {'accidents' }
    {'airfoil'   }
    {'cape'      }
    {'census'    }
    {'clown'     }
    {'detail'    }
    {'dmbanner'  }
    {'durer'     }
    {'earth'     }
    {'fatalities'}

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:{
                             ' .../build/runnable/matlab/toolbox/matlab/demos/airfoil.mat'
                             }
                     Folders: {'/mathworks/devel/bat/filer/batfs2561-0/Bdoc24b.2679053/build/runnable/matlab/toolbox/matlab/demos'}
    AlternateFileSystemRoots: [0x0 string]
                    ReadSize: 1
              OutputDataType: "same"
           OutputEnvironment: "cpu"

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.

Version History

Introduced in R2020a