Find which cell element that contains element.

조회 수: 1 (최근 30일)
Kay Raymond
Kay Raymond 2017년 12월 8일
댓글: Kay Raymond 2017년 12월 8일
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일
Use ismember first and then find
indx = find(cellfun(@(x) ismember(B,x),A))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by