How to use regexp in a cell array whose cells may contain cell entries

2 ビュー (過去 30 日間)
Ioannis Vourvachakis
Ioannis Vourvachakis 2022 年 1 月 8 日
コメント済み: Stephen23 2022 年 1 月 8 日
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 件のコメント
Ioannis Vourvachakis
Ioannis Vourvachakis 2022 年 1 月 8 日
I want to know where that text is appeared (anywhere), and I mean in which row of this array.
Stephen23
Stephen23 2022 年 1 月 8 日
"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

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2022 年 1 月 8 日
編集済み: Stephen23 2022 年 1 月 8 日
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)
ans = 35×1
193 194 195 196 197 198 199 200 201 202
model.subSystems{193}{:}
ans = 'Carbon fixation'

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by