i am facing error to know index of element

1 回表示 (過去 30 日間)
Shehab Tarek
Shehab Tarek 2020 年 4 月 4 日
回答済み: Tommy 2020 年 4 月 4 日
I know, that number, for example, 5, is an element in array X, but I don't know it's index. In Python, I can use:
X.index(5)
in addation i want to ignore the second element
I realized this function, using for loop and if statement, but did Matlab doesn't have build-in similar function?
for example:
A=[1 2 3 4 5 6 6 7 8 5]
res=find(5)==A;
the output: will be
5,10
i want to ignore 10
the result will be 5 only

回答 (1 件)

Tommy
Tommy 2020 年 4 月 4 日
find(A==5,1)
will give you just the first index in A which equals 5.

カテゴリ

Help Center および File ExchangeDenoising and Compression についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by