location of logical matrix

조회 수: 4 (최근 30일)
Cside
Cside 2019년 8월 22일
댓글: madhan ravi 2019년 8월 22일
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에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by