finding multiple vectors in a matrix

Christophe christophe.solere at gmail.com
Sat Oct 23 12:02:27 CEST 2010


Is there a fast way to search for a matrix like

a=[ 1 2 3; 4 5 6; 7 8 9];

in a larger set like

b=[1 2 3; 10 11 12; 1 2 3; 4 5 6; 20 30 40; 1 2 3];

where function(a,b) whould give something like

ans= [ 1 1; 1 3; 2 4; 1 6]

so the first element of a is found in the first, third and six places of 
b and the second element of a is found in the fourth place of b.

This can easily achieved usin loops, but I find loops every inefficiency 
in fast applications compare to the like of functions find, union or 
intersect.

Thanks






More information about the users mailing list