From help-request at octave dot org Sun Feb 13 12:24:46 2005 Subject: RE: Select elements according to the index From: "Chen, Minyu" To: "Henry F. Mollet" , "Todd Neal" Cc: "Octave_post" Date: Sun, 13 Feb 2005 18:25:52 -0000 Thank you both. It was not working in 2.1.40 which came directly with my Red Hat 9. However, as I just upgraded the package to 2.1.64, it works perfectly.=20 Thanks, Minyu Chen -----Original Message----- From: Henry F. Mollet [mailto:mollet at pacbell dot net]=20 Sent: 13 February 2005 17:30 To: Todd Neal; Chen, Minyu Cc: Octave_post Subject: Re: Select elements according to the index octave:24> a=3D[1 2 3; 4 5 6] a =3D 1 2 3 4 5 6 octave:25> b=3D[.1 .2 .3 .4 .5 .6 .7 .8] b =3D 0.10000 0.20000 0.30000 0.40000 0.50000 0.60000 0.70000 0.80000 octave:26> c=3Db(a) c =3D 0.10000 0.20000 0.30000 0.40000 0.50000 0.60000 Works on GNU Octave, version 2.1.46 (powerpc-apple-darwin6.6). Henry >=20 > What version of Octave are you using ? This is from 2.1.64 Debian Testing. >=20 > octave:1> a=3D[1 2 3; 4 5 6]; > octave:2> b=3D[.1 .2 .3 .4 .5 .6 .7 .8]; > octave:3> c=3Db(a) > c =3D >=20 > 0.10000 0.20000 0.30000 > 0.40000 0.50000 0.60000 >=20 >=20 > Todd >=20 on 2/13/05 8:04 AM, Todd Neal at tolchz at gmail dot com wrote: > On Sun, 13 Feb 2005 13:32:25 -0000, Chen, Minyu wrote: > ... >> Suppose I have an index matrix of 2 by 3, e.g. a=3D[1 2 3; 4 5 6] >>=20 >> And have a vector of 1 by 8, e.g. b=3D[.1 .2 .3 .4 .5 .6 .7 .8] >>=20 >> And I want to create a matrix c of 2 by 3 (the same dimension of a), >> with c(i,j)=3Db(a(i,j)), that's being said: >>=20 >> c=3D[.1 .2 .3; .4 .5 .6] >>=20 >> In matlab, as memory serves correctly, I can do it by typing: >>=20 >> c=3Db(a) >>=20 >> but this command in Octave will generate only a vector of 1 by 6: >>=20 >> c=3D[.1 .4 .2 .5 .3 .6] >>=20 >> How can I get the matrix I want? >>=20 >> Many Thanks, >> Minyu Chen >=20 >=20 ------------------------------------------------------------- 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 -------------------------------------------------------------