Clear Filters
Clear Filters

Find which cell element that contains element.

3 views (last 30 days)
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?

Accepted Answer

KL
KL on 8 Dec 2017
Edited: KL on 8 Dec 2017
Use ismember first and then find
indx = find(cellfun(@(x) ismember(B,x),A))

More Answers (0)

Categories

Find more on Data Types in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!