Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
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:44:06 +0000 (UTC)
Organization: Universite Laval
Lines: 33
Message-ID: <hsbu06$s57$1@fred.mathworks.com>
References: <hsbq4d$f2s$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1273592646 28839 172.30.248.37 (11 May 2010 15:44:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 11 May 2010 15:44:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 87696
Xref: news.mathworks.com comp.soft-sys.matlab:634644

"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.

More general way (that could work with other thing then 1 and zero ) :
C = (A == 1 & B ==1)