MATLAB: How to find index of nx2 matrix by comparing elements

find indxesnx2 matrix

Hi, giving a matrix of size nx2
A=[ 222,186;
222,187;
223,187]
giving 2 values i= 222 and j=187 i want to find the index the row that contain i on the first column and j on the seond wich is 2 here i want something like
i thought to do somthing like this
for k=1:size(A,1)
test=find(A(k,1)==i && A(k,2)==j)
if (test==1)
ind=k;
break;
end
end
i need only the first index like i did here but i want to avoid the loop.
Thanks

Best Answer

A=[ 222,186;
222,187;
223,187]
i = 222
j = 187
% two alternatives
r1 = find(A(:,1)==i & A(:,2)==j))
[tf,r2] = ismember(A,[i j],'rows')