Path: news.mathworks.com!not-for-mail
From: "Jos " <DELjos@jasenDEL.nl>
Newsgroups: comp.soft-sys.matlab
Subject: Re: sub-min
Date: Tue, 19 Feb 2008 07:58:09 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 28
Message-ID: <fpe26g$j5s$1@fred.mathworks.com>
References: <3d8a1aea-b86f-4987-aea9-0c2420ee73e5@i29g2000prf.googlegroups.com> <b21b9772-12c9-4842-a58e-34c1fc28faff@v3g2000hsc.googlegroups.com>
Reply-To: "Jos " <DELjos@jasenDEL.nl>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1203407889 19644 172.30.248.35 (19 Feb 2008 07:58:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 19 Feb 2008 07:58:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 870065
Xref: news.mathworks.com comp.soft-sys.matlab:452300


Ross <fed.rossi@gmail.com> wrote in message
<b21b9772-12c9-4842-a58e-34c1fc28faff@v3g2000hsc.googlegroups.com>...
> On Feb 18, 7:43 pm, Ross <fed.ro...@gmail.com> wrote:
> > Hi everyone,
> >
> > I have two 2-dim arrays, A and C. C is zeros and ones.
> > I and want to find min(A, [ ] , 2), but only considering
elements that
> > are ones in matrix C.
> >
> > Do you know a fast way to compute this in matlab?
> >
> > Thank you!
> > Ross
> 
> ok, I guess I will go with the brute force:
> 
> a = max(max(A));
> Ca = C.*a;
> Amin = min(Ca+A,[ ],2);
> 

B = A ; % work on a copy
B(C==0) = Inf ;
Amin = min(B,[],2)

hth
Jos