[scilab-Users] finding multiple vectors in a matrix

solerec at eircom.net solerec at eircom.net
Mon Oct 25 11:40:34 CEST 2010


Yes great solution. I was trying to stay away from loops. It seems to always lead to time inefficiency in fast application. But thanks a lot for your time.

Christophe
------Original Message------
From: Samuel GOUGEON
To: users at lists.scilab.org
ReplyTo: users at lists.scilab.org
Subject: Re: [scilab-Users] finding multiple vectors in a matrix
Sent: Oct 25, 2010 10:33

  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



Let your email find you with BlackBerry® from Vodafone


More information about the users mailing list