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

4 ビュー (過去 30 日間)
Nazmun Nahar Khan
Nazmun Nahar Khan 2021 年 2 月 26 日
コメント済み: Nazmun Nahar Khan 2021 年 2 月 26 日
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 件のコメント
tzela yaish
tzela yaish 2021 年 2 月 26 日
how do i create my own question ?
Nazmun Nahar Khan
Nazmun Nahar Khan 2021 年 2 月 26 日
Hi yaish, you need to go 'ask' in the top.

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

採用された回答

KSSV
KSSV 2021 年 2 月 26 日
編集済み: KSSV 2021 年 2 月 26 日
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 件のコメント
KSSV
KSSV 2021 年 2 月 26 日
編集済み: KSSV 2021 年 2 月 26 日
cellfun uses loop behind. find will be slow.
Nazmun Nahar Khan
Nazmun Nahar Khan 2021 年 2 月 26 日
Thanks

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by