location of logical matrix

6 次查看(过去 30 天)
Hi I have a 10 x 2 logical matrix and I would need to find out the location of the rows which both columns are ones i.e 1 1.
May I know how I may write for this? Thank you!

采纳的回答

madhan ravi
madhan ravi 2019-8-22
编辑:madhan ravi 2019-8-22
Since you have a logical matrix it’simply:
ix=all(matrix ,2); % logical indexing is efficient
Wanted=find(ix)
  6 个评论
Cside
Cside 2019-8-22
thank you madhan for being so clear with your answer :)
madhan ravi
madhan ravi 2019-8-22
While learning always visualize with a simple and short example to understand what's going on.

请先登录,再进行评论。

更多回答(1 个)

KSSV
KSSV 2019-8-22
Read about ismember
idx = round(rand(10,2)) ;
vec = [1 1] ;
[c,ia] = ismember(idx,vec,'rows') ;
iwant = find(c) ;
idx(c,:)
idx(iwant,:)

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by