Hi Robert Kern, thanks a lot for your help! Just another question, is there a way to do it in a matrix (that is, the intersection in the rows of 2 matrices)? The matlab version would be like: [c,ia,ib] = intersect(A,B,'rows') where A and B are matrices with the same number of columns. Best regards, Bernardo M. Rocha