Main Content

subset

Create new ensemble datastore from subset of existing ensemble datastore

Description

example

sens= subset(ens,idx)creates a new ensemble datastoresensfrom a subset of the existing ensemble datastoreensby extracting the ensemble members that correspond to the indices inidx.

Usesubsetwhen you want to perform ensemble operations on a specific ensemble member or group of ensemble members, and when using a sequence ofread命令与源合奏不提供the ensemble members that you want to process. For example, you can usesubsetto:

  • Extract only ensemble members with a specific fault condition.

  • Perform preliminary processing and feature generation on a smaller ensemble that contains a similar distribution of conditions to the larger ensemble.

  • Extract a single ensemble member with specific characteristics to isolate and explore member behavior.

Specify which members you want to extract using the index vectoridx. You can then operate on your extracted ensemble using the same techniques that you use for any data ensemble.

Examples

collapse all

Extract the ensemble member that you identify from an ensemble datastore and use a single read command to obtain the contents.

For this example, use the following code to create asimulationEnsembleDatastoreobject using data previously generated by running a Simulink® model at a various fault values (seegenerateSimulationEnsemble). The ensemble includes simulation data for five different values of a model parameter,ToothFaultGain. Because of the volume of data, theunzipoperation takes a few minutes.

unzipsimEnsData.zipens = simulationEnsembleDatastore(pwd,'logsout')
ens = simulationEnsembleDatastore with properties: DataVariables: [5x1 string] IndependentVariables: [0x0 string] ConditionVariables: [0x0 string] SelectedVariables: [5x1 string] ReadSize: 1 NumMembers: 5 LastMemberRead: [0x0 string] Files: [5x1 string]
ems_nm = ens.NumMembers
ems_nm = 5

The ensemble contains five files.

Extract the fourth ensemble member into a new, single-member ensemblesens.

idx = 4; sens = subset(ens,idx); sens_nm = sens.NumMembers
sens_nm = 1

senscontains one member. View the file name to confirm the member index.

sens.Files
ans = "/tmp/Bdoc21b_1757077_244449/tpca46d133/predmaint-ex43507974/TransmissionCasingSimplified_log_4.mat"

Resetsensto the first member and read the contents.

reset(sens) m4 = read(sens)
m4=1×5 tablePMSignalLogName SimulationInput SimulationMetadata Tacho Vibration _______________ ______________________________ _________________________________ ___________________ ___________________ {'logsout'} {1x1 Simulink.SimulationInput} {1x1 Simulink.SimulationMetadata} {20213x1 timetable} {20213x1 timetable}

m4contains the data for the extracted member.

创建一个simulation ensemble datastore from a subset of an existing simulation ensemble datastore.

创建一个simulationEnsembleDatastoreobject using data previously generated by running a Simulink® model at various fault values.

unzipsimEnsData.zipens = simulationEnsembleDatastore(pwd,'logsout'); ens_nm = ens.NumMembers
ens_nm = 5

The ensemble contains five files. View the file names.

ens.Files
ans =5x1 string"/tmp/Bdoc21b_1757077_244449/tpca46d133/predmaint-ex46856662/TransmissionCasingSimplified_log_1.mat" "/tmp/Bdoc21b_1757077_244449/tpca46d133/predmaint-ex46856662/TransmissionCasingSimplified_log_2.mat" "/tmp/Bdoc21b_1757077_244449/tpca46d133/predmaint-ex46856662/TransmissionCasingSimplified_log_3.mat" "/tmp/Bdoc21b_1757077_244449/tpca46d133/predmaint-ex46856662/TransmissionCasingSimplified_log_4.mat" "/tmp/Bdoc21b_1757077_244449/tpca46d133/predmaint-ex46856662/TransmissionCasingSimplified_log_5.mat"

Extract the first, third, and fifth files into a new ensemble.

idx = [1 3 5]; sens = subset(ens,idx); sens_nm = sens.NumMembers
sens_nm = 3

The new ensemble contains three members. View the file names.

sens.Files
ans =3x1 string"/tmp/Bdoc21b_1757077_244449/tpca46d133/predmaint-ex46856662/TransmissionCasingSimplified_log_1.mat" "/tmp/Bdoc21b_1757077_244449/tpca46d133/predmaint-ex46856662/TransmissionCasingSimplified_log_3.mat" "/tmp/Bdoc21b_1757077_244449/tpca46d133/predmaint-ex46856662/TransmissionCasingSimplified_log_5.mat"

The new ensemble contains the three files that you indexed.

Input Arguments

collapse all

Source ensemble datastore from which to extract members, specified as afileEnsembleDatastoreor asimulationEnsembleDatastoreobject. For an example of extracting a member from an ensemble datastore, seeExtract Specific Member from Ensemble Datastore.

Indices of source ensemble members to extract, specified as a numeric vector, an integer vector, or a logical vector. The number of elements in the vector must not exceed the number of members inens. For numeric or integer vectors, all indices must be positive. For logical vectors, the number of elements must be equal to the number of ensemble members inens. For an example of creating and using an index vector, seeCreate Subset of Ensemble Datastore.

Output Arguments

collapse all

Extracted ensemble datastore, returned as afileEnsembleDatastoreor asimulationEnsembleDatastoreobject.

Introduced in R2021a