Path: news.mathworks.com!not-for-mail
From: "Ulrik Nash" <uwn@sam.sdu.dk>
Newsgroups: comp.soft-sys.matlab
Subject: Identifying and counting common elements.
Date: Sat, 2 Nov 2013 18:58:08 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 9
Message-ID: <l53i00$s98$1@newscl01ah.mathworks.com>
Reply-To: "Ulrik Nash" <uwn@sam.sdu.dk>
NNTP-Posting-Host: rubyext-03-ls.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1383418688 28968 172.20.102.179 (2 Nov 2013 18:58:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 2 Nov 2013 18:58:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2106050
Xref: news.mathworks.com comp.soft-sys.matlab:804697

Hi Group,

I have two matrices (A and B) each containing 0's and 1's. All I need is to count the number of places where 1's exist in the same position in the two matrices., but besides looping through, I can't seem to find the solution. I have tried ismember and intersection, but the result was not correct.

For example, in the following
A = [1 0;0 0]
B = [1 1;1 0]

The answer needed is 1.