Path: news.mathworks.com!not-for-mail
From: "Alan B" <monguin61REM@OVEyahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Simple matrix manipulation question
Date: Thu, 16 Jul 2009 16:29:02 +0000 (UTC)
Organization: UT
Lines: 14
Message-ID: <h3nkge$ac0$1@fred.mathworks.com>
References: <h3lt89$b6e$1@fred.mathworks.com> <h3m1dc$5gs$1@fred.mathworks.com> <h3njiu$8m6$1@fred.mathworks.com>
Reply-To: "Alan B" <monguin61REM@OVEyahoo.com>
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 1247761742 10624 172.30.248.35 (16 Jul 2009 16:29:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 16 Jul 2009 16:29:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1446885
Xref: news.mathworks.com comp.soft-sys.matlab:556008


"jcurr Curran" <johncurran20@yahoo.com> wrote in message <h3njiu$8m6$1@fred.mathworks.com>...
> Right, but that method involves looping over each i. Is there a way to do this without loops?
> 
> "Darren Rowland" <darrenjremovethisrowland@hotmail.com> wrote in message <h3m1dc$5gs$1@fred.mathworks.com>...
> > Ok, I see what you want now
> > c(i) = min( A(1:b(i)) );

If I understand correctly, this should work:

z = meshgrid(1:k)>repmat(b',1,k); % use this to mask off the unwanted values with inf
A(z) = inf; 
min(A,[],2);

I didn't check for timing, a loop might be faster.