# How to find the position of a number in an cell-array?

1 view (last 30 days)
Nazmun Nahar Khan on 26 Feb 2021
Commented: Nazmun Nahar Khan on 26 Feb 2021
I have a cell array P= {[2,5], [3], [], [1,14], [], [9]}. I want to find out the number of cell where value 14 is located. Like, here 14 is located inside the cell number 4.
How can I do that?
##### 2 CommentsShowHide 1 older comment
Nazmun Nahar Khan on 26 Feb 2021
Hi yaish, you need to go 'ask' in the top.

Sign in to comment.

### Accepted Answer

KSSV on 26 Feb 2021
Edited: KSSV on 26 Feb 2021
P= {[2,5], [3], [], [1,14], [], [9]} ;
N = length(P) ;
val = 14 ;
for i = 1:N
idx = ismember(14,P{i}) ;
if any(idx)
break
end
end
i
P{i}
##### 5 CommentsShowHide 4 older comments
Nazmun Nahar Khan on 26 Feb 2021
Thanks

Sign in to comment.

### Categories

Find more on Loops and Conditional Statements 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!

Translated by