From help-request at octave dot org Fri Jun 18 13:34:03 2004 Subject: Re: no way for simple matrix lookup ? From: Julius Smith To: "D. Goel" Cc: help at octave dot org Date: Fri, 18 Jun 2004 11:35:42 -0700 Oops - I meant diag(A(b',c)) of course -- jos At 11:30 AM 6/18/2004, Julius Smith wrote: >How about A(diag(b',c)) ? > >-- jos > >At 10:33 AM 6/16/2004, 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 [1 >>2 3 4]. >> >> >>Mike Miller writes: >> >> >> > D = A(b,c) >> > >> > And your variable D will be a matrix with size(D)=[length(b), >> > length(c)]. You can transform it into a vector using D=D(:), or you >> > can do this: >> > >> > D = reshape(A(b, c), length(b)*length(c), 1) >> > >> > You don't have to loop over 'i'. >> > >> > Best, >> > >> > 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 >>------------------------------------------------------------- > >_____________________________ >Julius O. Smith III >Assoc. Prof. of Music and (by courtesy) Electrical Engineering >CCRMA, Stanford University >http://www-ccrma.stanford.edu/~jos/ > > > >------------------------------------------------------------- >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 >------------------------------------------------------------- _____________________________ Julius O. Smith III Assoc. Prof. of Music and (by courtesy) Electrical Engineering CCRMA, Stanford University http://www-ccrma.stanford.edu/~jos/ ------------------------------------------------------------- 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 -------------------------------------------------------------