Path: news.mathworks.com!not-for-mail
From: "Henry " <henry@fullspectrumengineering.com>
Newsgroups: comp.soft-sys.matlab
Subject: How to do vectorize this simple code?
Date: Fri, 14 Nov 2008 22:09:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 10
Message-ID: <gfkstu$1id$1@fred.mathworks.com>
Reply-To: "Henry " <henry@fullspectrumengineering.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1226700543 1613 172.30.248.37 (14 Nov 2008 22:09:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 14 Nov 2008 22:09:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1601498
Xref: news.mathworks.com comp.soft-sys.matlab:500913


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.