[Tutor] indexing of arrays in numeric
Deirdre Hackett
deirdrehac@lycos.co.uk
Mon Feb 10 13:40:03 2003
This is a multi-part message in MIME format.
------=_NextPart_000_0009_01C2CD36.88AD1DD0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I downloaded numeric to help me with my array problems....
I either have the data in this format,
data =3D ([2345,4567,-6754])
or =20
xin =3D 2345
yin =3D 4567
zin =3D -6754
I created an array of 10 rows and 3 columns,
datab =3D zeros((10,3))
I want the 3 values to be along each row but I am having trouble =
figuring out how to index the array specifically.
for x, in arange(28):
put(datab, [x], xin)
put(datab, [x+1], yin)
put(datab, [x+2], zin)
This obviously does not work but I hope it will give you an idea of what =
I mean.
Not sure how the sequence works. I know that you can say,
a =3D arrayrange(9)
a.shape =3D (3,3)
print a[0,0] #will give you first row, first column,ie first element
print a[0] #get first row
I want to be able to do this except the opposite way around.
Thanks=20
Deirdre
------=_NextPart_000_0009_01C2CD36.88AD1DD0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I downloaded numeric to help me with my =
array=20
problems....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I either have the data in this =
format,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> data =3D =
([2345,4567,-6754])<BR>or=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> xin =3D =
2345</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> yin =3D =
4567</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> zin =3D =
-6754</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I created an array of 10 rows and 3=20
columns,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> </FONT><FONT face=3DArial=20
size=3D2> datab =3D zeros((10,3))</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I want the 3 values to be along each =
row but I am=20
having trouble figuring out how to index the array =
specifically.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>for x, in =
arange(28):<BR> =20
put(datab, [x], xin)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> put(datab, [x+1],=20
yin)<BR> put(datab, [x+2], zin)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>This obviously does not work but I hope =
it will=20
give you an idea of what I mean.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Not sure how the sequence works. I know =
that you=20
can say,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>a =3D arrayrange(9)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>a.shape =3D (3,3)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>print a[0,0] #will give you first row, =
first=20
column,ie first element</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>print a[0] #get first =
row</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> </DIV>
<DIV>I want to be able to do this except the opposite way around.</DIV>
<DIV>Thanks </DIV>
<DIV>Deirdre</FONT></DIV></BODY></HTML>
------=_NextPart_000_0009_01C2CD36.88AD1DD0--