finding specific values' rows numbers in an array

1 次查看(过去 30 天)
a=[11;4;3;99;5;6;7];
b=[4;7];
I need to find which rows in a matrix include 4,7. The answer must be 2th and 7th rows w.r.t. the solution.

采纳的回答

Guillaume
Guillaume 2015-6-29
编辑:Guillaume 2015-6-29
Use the second return value of ismember:
[~, row] = ismember(b, a)
row will be 0 if the value in b is not found in a.

更多回答(1 个)

Thorsten
Thorsten 2015-6-29
编辑:Thorsten 2015-6-29
find(a==4)
find(a==7)
  1 个评论
sermet
sermet 2015-6-29
how can I adopt this solution as creating loop. Because arrays' rows are several hundreds.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by