Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Simple matrix manipulation question
Date: Thu, 16 Jul 2009 17:30:36 +0000 (UTC)
Organization: Mitre Corp
Lines: 9
Message-ID: <h3no3s$2kc$1@fred.mathworks.com>
References: <h3lt89$b6e$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 1247765436 2700 172.30.248.38 (16 Jul 2009 17:30:36 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 16 Jul 2009 17:30:36 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2318
Xref: news.mathworks.com comp.soft-sys.matlab:556033


"jcurr Curran" <johncurran20@yahoo.com> wrote in message <h3lt89$b6e$1@fred.mathworks.com>...
> Hi all,
> 
> Suppose I have a n x k matrix A and a n x 1 column vector b. b contains integers between 1 and k. I want to produce a n x 1 column vector c, which is defined by c(i) = min {A(i,1),A(i,2),...,A(i,b(i)}. This would be easy with loops, but I want code which will run as fast as possible (the matrices are large, and the operation will be performed many times).

Vectorized code MAY NOT NECESSARILY run as fast as code with loops, especially for large matricies.

> 
> To clarify, if b were (k,...,k)' then c would contain the minimum elements in each row of A.