how to find the indices of some values in a matrix

2 次查看(过去 30 天)
Hi everybody,
I have a 501*2 matrix,and I want to find the indices of two elements. I use find(X==x0) and find(X==x1) to find the elements, I know that these elements exist, but it give me nothing! it gives me one but not the other one! what is the solution? I used strfind(X,x0) also but it has the same problem!

回答(1 个)

Star Strider
Star Strider 2014-5-28
It should find all of them.
Try:
[r0,c0] = find(X==x0)
[r1,c1] = find(X==x1)
  5 个评论
Mahdi
Mahdi 2014-5-28
Oh wow! I totally forgot about it! I edited my answer to fix it.
Star Strider
Star Strider 2014-5-28
Edited mine also, since my previous edit now has no context.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by