searching part of matrix in every cell of a cell array

1 回表示 (過去 30 日間)
Katharina
Katharina 2017 年 3 月 23 日
コメント済み: Katharina 2017 年 3 月 23 日
A is a cell array containing matrices with different sizes in each cell:
A={[5x4],[5x3],[5x20]}
I know, it is possible to search the cell array for a particular number (code) using cellfun.
find( cellfun(@(f) (f==code), A )
Is it possible to search just the first row of the matrices in each cell array for that code? What I was trying to do, but does not work, is:
find( cellfun(@(f) (f==code), A{:}(1,:))
I need the indices of cells which contain the code in the first row. Is there a solution without using a for loop?
  2 件のコメント
Matt J
Matt J 2017 年 3 月 23 日
編集済み: Matt J 2017 年 3 月 23 日
I think you'll find that
find( cellfun(@(f) (f==code), A )
does not work for the first scenario you describe.
Katharina
Katharina 2017 年 3 月 23 日
find( cellfun(@(f) any(f==code), A )
is what I meant, sorry

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

採用された回答

Matt J
Matt J 2017 年 3 月 23 日
編集済み: Matt J 2017 年 3 月 23 日
find( cellfun(@(f) any(f(1,:) == code), A)
  1 件のコメント
Katharina
Katharina 2017 年 3 月 23 日
Works! Thanks so much!!!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by