Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Find values in Matrix
Date: Mon, 23 Mar 2009 05:03:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 13
Message-ID: <gq7566$bm5$1@fred.mathworks.com>
References: <gq6n61$di7$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 1237784582 11973 172.30.248.37 (23 Mar 2009 05:03:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 23 Mar 2009 05:03:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:526838

"matthew mccarthy" <batter8@aol.com> wrote in message <gq6n61$di7$1@fred.mathworks.com>...
> I am having trouble finding values in two matrices. I have two matrices that are both 215x215 and I need to find two values in one matrix that are also in the other. The problem I am having is I can only find one value. I am trying to use the [r,c]=find(m=v).
> Thanks for the help

  What precisely do you mean by "find two values in one matrix that are also in the other"?  I would interpret this language as meaning that the locations of common elements in the two matrices do not have to be the same.  In that case, the use of 'find' is inappropriate.  It only finds elements that match both in value and in location.

  Instead you should use 'intersect'.

 c = intersect(a,b);

where a and b are the two matrices.  The vector c will contain all elements common to both a and, regardless of location.  If c contains more than two elements, the first two (or any two) would satisfy your requirements.

Roger Stafford