subset
Description
Examples
Create Signal Datastore with Subset Based on File Name
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
sds
— Signal datastore
signalDatastore
object
Signal datastore, specified as a signalDatastore
object.
indices
— Indices of files in subset
vector of indices | logical vector
Specify indices
as:
A vector containing the indices of files or members to be included in
sdssubset
. Thesubset
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 insdssubset
.
Data Types: double
| logical
Output Arguments
sdssubset
— Subset of signal datastore
signalDatastore
object
Subset of signal datastore, returned as a signalDatastore
object.
Version History
Introduced in R2020a
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)