How to find in cell structures?

6 ビュー (過去 30 日間)
JamJan
JamJan 2019 年 8 月 7 日
コメント済み: JamJan 2019 年 8 月 7 日
I have the following cell structure:
1x30 double
1x23 double
1x23 double
1x23 double
1x23 double
1x23 double
1x23 double
1x25 double
1x35 double
I want to find whether a number is present in one of these and want to know the index of that. So for instance the number 5 is present in double 1, 5 and 7, so the output should be [1 5 7]. Can this be done?
  4 件のコメント
KSSV
KSSV 2019 年 8 月 7 日
Read about ismember, find.
Adam
Adam 2019 年 8 月 7 日
編集済み: Adam 2019 年 8 月 7 日
Off the top of my head, something like this may work:
find( cellfun( @(x) any( find( x == 5 ) ), myCell, 'UniformOutput', false ) )
where myCell is your cell array.
At least it may give you ideas to get to the right solution, though I'm sure someone else will quickly come along with a correct or better solution if this is not it!

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

採用された回答

madhan ravi
madhan ravi 2019 年 8 月 7 日
編集済み: madhan ravi 2019 年 8 月 7 日
v=cellfun(@(x) any( x == 5 ), yourcell);
Wanted = find(v) % Adam was almost right , but a minute tweak
  3 件のコメント
madhan ravi
madhan ravi 2019 年 8 月 7 日
Thank you Stephen!
JamJan
JamJan 2019 年 8 月 7 日
Thank you guys!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by