Finding indices when vectors is used

2 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by