[Scilab-users] Search for a subvector in a vector

Samuel Gougeon sgougeon at free.fr
Wed Feb 8 14:05:35 CET 2017


Hello Christophe,

Having the same need, i have recently implemented a vectorized solution, 
by the way truly extended to hypermatrices (up to now only the first 
page of hypermatrix was considered and searched in).

I am posting it on the CodeReview. I still need a bit of time to update 
the help page. It shall be available in 6.1, but you can download and 
use it from the codeReview (will post the URL here just after commiting).

Cheers
Samuel

Le 08/02/2017 à 11:20, Dang Ngoc Chan, Christophe a écrit :
> Hello,
>
> I probably missed something obvious but here is my trouble :
> I have a vector a = 1:6
> and want to locate b = [2 3 4] inside a (the result being 2).
>
> So I know members() which locate any of the elements of b inside a
> and vectorfind() which can search a vector inside a matrix.
>
> I searched the archive of the list and found topics about Matlab ismember()
> and locating a phrase in a text.
>
> But none of these are convenient.
>
> As my vector is rather small, I can do
>
> aa = [a(1:$-2)  ;  a(2:$-1) ; a-3:$)]
>
> vectorfind(aa, b, "c")
>
> but I wonder if there is a better (vectorised) solution?
>
> Regards
>
> --
> Christophe Dang Ngoc Chan
> Mechanical calculation engineer
>
> Sidel Group
> Sidel Blowing & Services
> Avenue de la Patrouille de France
> CS 60627, Octeville-sur-Mer
> 76059 Le Havre cedex, France
>
>
> Tel: 33(0)2 32 85 89 32
> Fax: 33(0)2 32 85 91 17
>
> <http://www.sidel.com/>
> <mailto:christophe.dang at sidel.com>
>
> This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>




More information about the users mailing list