Path: news.mathworks.com!newsfeed-00.mathworks.com!solaris.cc.vt.edu!news.vt.edu!news.glorb.com!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!aioe.org!.POSTED!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: find all numbers in a vector
Date: Mon, 03 Dec 2012 19:18:06 -0600
Organization: Aioe.org NNTP Server
Lines: 20
Message-ID: <k9jj0e$c72$1@speranza.aioe.org>
References: <k9jerd$h6o$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: d9rkuHWV+LYy/jluNrFC/w.user.speranza.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0
X-Notice: Filtered by postfilter v. 0.8.2
Xref: news.mathworks.com comp.soft-sys.matlab:784100

On 12/3/2012 6:07 PM, Petra wrote:
> Hi all,
> I cant find a solution without a loop for this problem:
> I got 2 vectors
>   a=[2    3    14    15    16    17    18    33    34    35]
> b=[17 18 35 60 61 62]
> and I try to find all numbers and position in a which are in b.
> The answer should be: 6 7 8 10
> Thanks for help
>

You answer is wrong. Here is the correct answer

EDU>> find(ismember(a,b)==1)

ans =

      6     7    10