[scilab-Users] finding multiple vectors in a matrix

Samuel GOUGEON Samuel.Gougeon at univ-lemans.fr
Mon Oct 25 11:33:25 CEST 2010


  Hello Christophe,

----- Message d'origine -----
De : Christophe
Date : 23/10/2010 12:02:
> 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

vectorfind(b,a(1,:),"r")
will do half the job.
Then, you may have to use a loop over the a's rows,
or you may code your own function.

Regards
Samuel




More information about the users mailing list