Searching for part of variable name

조회 수: 153 (최근 30일)
Finley Peddle
Finley Peddle 2020년 5월 4일
댓글: Adam Danz 2020년 5월 5일
I am working with the fileEnsembleDatastore tool from the predictive maintenance toolbox.
In this, you need to list DataVariables, ConditionVariables and SelectedVariables.
The data I am working with is in .mat format, each file containing 4 variables:
I want to use each variable, but only the suffix as the start of each variable name is different from file to file.
E.g.
ensembleTrain = fileEnsembleDatastore(fileLocation, fileExtension);
ensembleTrain.ReadFcn = @readBearingData;
ensembleTrain.DataVariables = ["BA"; "DE"; "FE"; "RPM"];
ensembleTrain.ConditionVariables = ["label";"file"];
ensembleTrain.WriteToMemberFcn = @writeBearingData;
ensembleTrain.SelectedVariables = ["label"; "file"; "BA"; "DE"; "FE"; "RPM"]
%I'm trying to use characters that are common between the variable names
Edit: How do I search for variables with names that include parts of the name, i.e. BA, DE etc.

채택된 답변

Adam Danz
Adam Danz 2020년 5월 4일
I don't see a question in your query. If you've got a list of variable names and you're looking for partial matches, check out the contains() function or if you need something for rigorous, regexp().
  댓글 수: 1
Adam Danz
Adam Danz 2020년 5월 5일
I haven't worked with fileEnsembleDatastore but if you can get a list of variable names, you can use my answer to solve the problem.
A typical way of listing all variable names in the current workspace is,
vars = who();
then,
TF = contains(vars, 'DE_time');
vars(TF)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Manage System Data에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by