position of values in a matrix
1 回表示 (過去 30 日間)
古いコメントを表示
i have a set of matrix
23 24
35 2
12 19
24 23
12 15
26 17
i want to know the position of in the matrix of [35 2], [12 15]
which is 2 and 5
is it possible to get the position of it.
0 件のコメント
回答 (2 件)
Alex Mcaulley
2019 年 10 月 29 日
A = [23 24
35 2
12 19
24 23
12 15
26 17]
loc = find(ismember(A,[35 2],'rows'))
loc =
2
1 件のコメント
Alex Mcaulley
2019 年 10 月 29 日
Another option:
[~,loc,~] = intersect(A,[35 2],'rows')
loc =
2
ME
2019 年 10 月 29 日
If I understand what you are asking then you could use:
Z=[23 24; 35 2; 12 19; 24 23; 12 15; 26 17];
M=[35 2; 12 15];
pos = find(ismember(Z, M, 'rows') == 1);
where Z is your original matrix, M is a matrix of the items you want to search for and pos is the output containing the locations of those items.
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!