Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: find function
Date: Mon, 5 Jan 2009 13:09:01 +0000 (UTC)
Organization: The MathWorks Inc
Lines: 19
Message-ID: <gjt0pd$op1$1@fred.mathworks.com>
References: <gjt08k$mt1$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1231160941 25377 172.30.248.38 (5 Jan 2009 13:09:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 5 Jan 2009 13:09:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869871
Xref: news.mathworks.com comp.soft-sys.matlab:509840


"Branko" <branko_b@hotmail.com> wrote in message <gjt08k$mt1$1@fred.mathworks.com>...
> Let's say that I have a random matrix:
> A=ceil(randn(10,1));
> and I want to find -1 and 2 values in the matrix. Which is done by following command
> a=find(A==-1);
> b=find(A==2);
> However I' d like to use single command which in this case is:
> c=find(A==-1 & A==2);
> But I got empty matrix.Where is the cache. 
> Thanks.

That's because a number cannot be both -1 AND 2. Are you perhaps looking for either -1 OR 2?

Then do

c = find(A==-1 | A==2);


jiro