Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Avoiding for loop
Date: Mon, 9 Mar 2009 22:15:03 +0000 (UTC)
Organization: AIR Worldwide Corp
Lines: 19
Message-ID: <gp44d7$bgd$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1236636903 11789 172.30.248.37 (9 Mar 2009 22:15:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 9 Mar 2009 22:15:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1076536
Xref: news.mathworks.com comp.soft-sys.matlab:523611


Are there anyway I can avoid using FOR loop for the case shown below?

oriX  = [1	2	3	4	5
10	20	30	40	50
100	200	300	400	500
1000	2000	3000	4000	5000];
rowindx = [2 4 1 3 3];
newX= zeros( 1, length(rowindx));

for ii = 1: 5
newX(ii) = oriX(  rowindx(ii), ii);
end


newX =

          10        2000           3         400         500

Thanks a lot in advance