|
From: | Quentin Spencer |
Subject: | Re: no way for simple matrix lookup ? |
Date: | Wed, 16 Jun 2004 13:08:16 -0500 |
User-agent: | Mozilla Thunderbird 0.6 (X11/20040519) |
D. Goel wrote:
Mike, that doesn't work, your recipe below is the first thing I tried.Example, A = [1 3; 2 4] b=c=[1 2]. The answer needed is [1 4], but both of your answers below give me [12 3 4].
Try this: octave>d=A((b-1)*size(A,2)+c) d = 1 4 This is general enough to work for all 2-D arrays. You would have to extend the concept for N-D arrays. There could be a function that I don't know about that already does this. If there isn't, someone should contribute one (I don't know what you'd call it). regards, Quentin ------------------------------------------------------------- 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 -------------------------------------------------------------
[Prev in Thread] | Current Thread | [Next in Thread] |