Find which cell element that contains element.

I have a cell array similar to A, where all array element in all cells are distinct. I want to find in which cell element the value B is.
A = {[1 2 3 4 5], [6 7 8], [9 10 11 12 13 14 15 16], ...};
B = 8;
C = cellfun(@find, A, B) % This doent work
>> C = 2 % desired output
Any ideas?

 採用された回答

KL
KL 2017 年 12 月 8 日
編集済み: KL 2017 年 12 月 8 日

0 投票

Use ismember first and then find
indx = find(cellfun(@(x) ismember(B,x),A))

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

質問済み:

2017 年 12 月 8 日

コメント済み:

2017 年 12 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by