Thread Subject: get position of elements of subvector in a vector

Subject: get position of elements of subvector in a vector

From: stat

Date: 8 May, 2009 07:59:01

Message: 1 of 2

Hello I am looking for a quick way to find positions in a vector of elements of subvector

Ex :

function([1 1 2 2 3 4 5 6 7 7 8],[1 2 7]) = [1 2 3 4 9 10]
I could loop and do a find on 1,2,7 but looking for a vectorized way.

Cheers

Subject: get position of elements of subvector in a vector

From: John

Date: 13 May, 2009 16:01:04

Message: 2 of 2

x=[1 1 2 2 3 4 5 6 7 7 8];
y=[1 2 7];
anwer = find(ismember(x,y));


"stat " <statquant@gmail.com> wrote in message <gu0oo5$2ld$1@fred.mathworks.com>...
> Hello I am looking for a quick way to find positions in a vector of elements of subvector
>
> Ex :
>
> function([1 1 2 2 3 4 5 6 7 7 8],[1 2 7]) = [1 2 3 4 9 10]
> I could loop and do a find on 1,2,7 but looking for a vectorized way.
>
> Cheers

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com