필터 지우기
필터 지우기

how to find the row index of specific vector in a matrix

조회 수: 102 (최근 30일)
d d
d d 2019년 4월 7일
댓글: AKASH BHOYAR 2022년 5월 23일
Hi everyone, suppose there's a marix [2 0;-2 1;2 3], I want find the row index of [-2 1], i.e., [-2 1] is on the second row of [2 0;-2 1;2 3]. how to realize it in matlab? Many thanks!

채택된 답변

Star Strider
Star Strider 2019년 4월 7일
Try this:
A = [2 0;-2 1;2 3];
RowIdx = find(ismember(A, [-2 1],'rows'))
producing:
RowIdx =
2
  댓글 수: 2
Elizabeth Thompson
Elizabeth Thompson 2022년 3월 11일
How would I do this if the vector I am looking for is a subset of A? i.e. If A is a matrix with three columns, and I want to find which row a 1x2 array x is in of A? idx=find(ismember(A,x,'rows')) obviously wouldn't work here, but is there a way to do this still using the find(ismember()) command?
AKASH BHOYAR
AKASH BHOYAR 2022년 5월 23일
@Star Strider Very Helpful. Thanks 3000!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by