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

Dang Ngoc Chan, Christophe Christophe.Dang at sidel.com
Wed Feb 8 11:20:20 CET 2017


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.



More information about the users mailing list