Arul - if we assume that your b matrix has floating point values (as opposed to integers), then you may have to compare each value of b with each value in the third column of a and consider them identical if their absolute difference is less than some tolerance. For example,
tol = 0.00001;
valb = b(k);
vala = a(m);
if abs(valb- vala) < tol
The above should provide a starting point from which you can elaborate on to solve your question.