Path: news.mathworks.com!not-for-mail
From: Loren Shure <loren@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Match matrix elements
Date: Tue, 20 Jan 2009 11:16:01 -0500
Organization: The MathWorks
Lines: 46
Message-ID: <MPG.23dfc2bb167363f998992c@news.mathworks.com>
References: <gl4esv$t3e$1@fred.mathworks.com>
NNTP-Posting-Host: vpn-client-122-21-ah.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1232468171 9397 144.212.122.21 (20 Jan 2009 16:16:11 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 20 Jan 2009 16:16:11 +0000 (UTC)
User-Agent: MicroPlanet-Gravity/2.70.2067
Xref: news.mathworks.com comp.soft-sys.matlab:512735


In article <gl4esv$t3e$1@fred.mathworks.com>, bobbaNO@mfn.SPAM.unipmn.it 
says...
> Hi, I have two matrix A and B:
> 
> A = 43000000 x 5
> B = 1 x 5
> 
> I show an example to clarify the target:
> 
> A = [11 22 34 56 89             B = [11 66 44 40 90}
>        23 44 11 20 66
>        79 54 32 17 89
>        11 66 21 45 90
>         ... ... ... ... ...]
> 
> RESULTS = [1 0 0 0 0
>                   0 1 1 0 1
>                   0 0 0 0 0
>                   1 1 0 0 1
>                   .. .. .. .. ..]
> 
> I would like to build a matrix (RESULTS) in which appears 1 if an element of B is present in A and zero if not present.
> I used "ismember" function but the error HELP OF MEMORY appears.
> 
> Can you help me to solve problems in a short time?
> 
> Thanks
> 
> Marco
> 
> 

You inspired me to blog on this topic: 
http://blogs.mathworks.com/loren/2009/01/20/more-ways-to-find-matching-
data/

The short answer is:

FinalAnswer = ismember(A,B)

will get you the results you are looking for.


-- 
Loren
http://blogs.mathworks.com/loren