Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Match matrix elements
Date: Tue, 20 Jan 2009 15:50:18 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 33
Message-ID: <gl4rrq$fo$1@fred.mathworks.com>
References: <gl4esv$t3e$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1232466618 504 172.30.248.37 (20 Jan 2009 15:50:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 20 Jan 2009 15:50:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:512731


"Bobba Marco" <bobbaNO@mfn.SPAM.unipmn.it> wrote in message <gl4esv$t3e$1@fred.mathworks.com>...
> 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

  I wouldn't be surprised if you are running out of memory, Marco.  If you are using 'double' in A, it is filling up 43000000 x 5 x 8 = 1.72 gigabytes of  contiguous memory.  Creating room for 'RESULTS' will add substantially to this total.  The 'ismember' function is the correct one to be using, but it also will need great quantities of memory to carry out its task in this case.  You may be forced to work with smaller-sized matrices.  The limitation is not matlab but the available resources on your computer.

Roger Stafford