Finding indices when vectors is used

1 回表示 (過去 30 日間)
Mateusz
Mateusz 2012 年 2 月 20 日
編集済み: Matt J 2013 年 10 月 17 日
Assume we have x = [1,2,3,1]; If I execute idx = find(x == 1) then idx == [1,4]. Is there similar command for extracting more indices I am interested in, something like find(x == [1,3]) == [1,3,4].
Of course I would like to avoid loops.
-- Ok, but what if we allow repetitions? For instance: find(x == [1,3,1]) == [1,1,3,4,4] Can we do this without using loops?

採用された回答

the cyclist
the cyclist 2012 年 2 月 20 日
I think you want the ismember() command.
  2 件のコメント
Mateusz
Mateusz 2012 年 2 月 20 日
Looks exactly what I am looking for, thanks :)
Mateusz
Mateusz 2012 年 2 月 20 日
Ok, but what if we allow repetitions? For instance: find(x == [1,3,1]) == [1,1,3,4,4] Can we do this without using loops?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by