Path: news.mathworks.com!not-for-mail
From: "Ulrik Nash" <uwn@sam.sdu.dk>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Creating a matrix of 1's and 0's by comparing values in two other matrixes
Date: Tue, 11 May 2010 15:10:08 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 40
Message-ID: <hsbs0g$i5b$1@fred.mathworks.com>
References: <hsbq4d$f2s$1@fred.mathworks.com> <hsbr0l$cip$1@fred.mathworks.com>
Reply-To: "Ulrik Nash" <uwn@sam.sdu.dk>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1273590608 18603 172.30.248.37 (11 May 2010 15:10:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 11 May 2010 15:10:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2106050
Xref: news.mathworks.com comp.soft-sys.matlab:634626

"Jos (10584) " <#10584@fileexchange.com> wrote in message <hsbr0l$cip$1@fred.mathworks.com>...
> "Ulrik Nash" <uwn@sam.sdu.dk> wrote in message <hsbq4d$f2s$1@fred.mathworks.com>...
> > Hi Everyone,
> > 
> > Suppose I have a matrix A of 1's and 0's:
> > 
> > A = 
> > 
> > 1 0 1
> > 0 0 1
> > 1 1 0
> > 
> > and another matrix B of 1's and 0's
> > 
> > B =
> > 
> > 1 1 0
> > 1 0 0
> > 0 1 0
> > 
> > now I wish to create a third matrix C of same dimension and A and B, which contains 1's where A = B = 1, and 0's otherwise:
> > 
> > C =
> > 
> > 1 0 0
> > 0 0 0
> > 0 1 0
> > 
> > How can this be done?
> > 
> > /Ulrik.
> 
> One of the many, many ways:
> 
> C = A .* B
> 
> hth
> Jos

Thanks Jos!