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$>
References: <gq6n61$di7$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1237784582 11973 (23 Mar 2009 05:03:02 GMT)
NNTP-Posting-Date: Mon, 23 Mar 2009 05:03:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:526838

"matthew mccarthy" <> wrote in message <gq6n61$di7$>...
> 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