フィルターのクリア

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

134 ビュー (過去 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 Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by