[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: extracting elements
From: |
Mike Miller |
Subject: |
Re: extracting elements |
Date: |
Sat, 30 Apr 2005 19:13:40 -0500 (CDT) |
On Sat, 30 Apr 2005, Mike Miller wrote:
...I can get what I want by doing this:
for i=1:length(I), Y(i,:)=X(I(i),J(i,:)); end
Y =
1 3
6 8
17 20
14 15
But I think there must be a way to do this sort of thing without a for
loop. Any suggestions? Thanks in advance.
I think I've got it:
X(I*ones(1,size(J,2))+size(X,1)*(J-1))
Mike
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------