How to use regexp in a cell array whose cells may contain cell entries
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ioannis Vourvachakis
le 8 Jan 2022
Commenté : Stephen23
le 8 Jan 2022
Hello,
Ι have the following cell array
I want to use -regexp to find where 'Carbon fixation' is written.
I would use: regexp(model.subSystems,'Carbon fixation');
The problem is that some cells contain cell entries, so this is a problem.
I want to find where (and especially in which row) 'Carbon fixation' is written, in any cell in any cell entry.
Can anyone help me? Thank you!
4 commentaires
Stephen23
le 8 Jan 2022
"The problem is that some cells contain cell entries, so this is a problem. "
All of them do:
>> all(cellfun(@iscell,model.subSystems))
ans =
logical
1
Réponse acceptée
Stephen23
le 8 Jan 2022
Modifié(e) : Stephen23
le 8 Jan 2022
Your data:
S = load('model.subSystems.mat');
model = S.model;
Getting indices of nested cells which contain the requested text:
fnh = @(c)any(~cellfun(@isempty,regexpi(c,'Carbon fixation')));
idx = cellfun(fnh,model.subSystems);
Checking:
find(idx)
model.subSystems{193}{:}
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!