how to find the indices of some values in a matrix

1 view (last 30 days)
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!

Answers (1)

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

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!