bsxfun -
find(all(bsxfun(@eq,A(:,1:2),[k,j]),2) | all(bsxfun(@eq,A(:,2:3),[k,j]),2))
bsxfun, post on benchmarked results, .
№1:
A =
1 4 5
1 5 7
6 7 1
4 5 6
2 3 1
k =
6
j =
7
>> find(all(bsxfun(@eq,A(:,1:2),[k,j]),2) | all(bsxfun(@eq,A(:,2:3),[k,j]),2))
ans =
3
№ 2:
A =
1 4 5
1 5 7
1 6 7
4 5 6
2 3 1
k =
6
j =
7
>> find(all(bsxfun(@eq,A(:,1:2),[k,j]),2) | all(bsxfun(@eq,A(:,2:3),[k,j]),2))
ans =
3