MATLAB: How to find the row index of specific vector in a matrix

arrayismembermatrix

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!

Best Answer

Try this:
A = [2 0;-2 1;2 3];
RowIdx = find(ismember(A, [-2 1],'rows'))
producing:
RowIdx =
2