Path: news.mathworks.com!not-for-mail
From: "Kenneth Eaton" <Kenneth.dot.Eaton@cchmc.dot.org>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to do vectorize this simple code?
Date: Fri, 14 Nov 2008 22:15:07 +0000 (UTC)
Organization: Cincinnati Children's Hospital Research Center
Lines: 16
Message-ID: <gfkt9b$7an$1@fred.mathworks.com>
References: <gfkstu$1id$1@fred.mathworks.com>
Reply-To: "Kenneth Eaton" <Kenneth.dot.Eaton@cchmc.dot.org>
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 1226700907 7511 172.30.248.35 (14 Nov 2008 22:15:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 14 Nov 2008 22:15:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1165924
Xref: news.mathworks.com comp.soft-sys.matlab:500916


"Henry " <henry@fullspectrumengineering.com> wrote in message <gfkstu$1id$1@fred.mathworks.com>...
> I want to vectorize this simple snippet:
> 
> for i=1:num_elements
>     y(i)=my_matrix(row(i),col(i));
> end
> 
> I tried y=my_matrix(row,col)
> and y=my_matrix([row col])
> 
> but nothing seems to work.  Any pointers?  Thanks.

Check out the SUB2IND function.

hth,
Ken