Re: Getting coordinates of array member-
- To: mathgroup at smc.vnet.net
- Subject: [mg26251] Re: [mg26247] Getting coordinates of array member-
- From: Maarten.vanderBurgt at icos.be
- Date: Sun, 10 Dec 2000 00:19:28 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Herbert, try this: In[2] := M = Partition[Range[1, 9], 3] Out[2] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} In[3] := M[[3, 1]] Out[3] = 7 In[4] := Position[M, 7] Out[4 ]= {{3, 1}} Maarten van der Burgt Leuven, Belgium "Stephane Hebert" <stephhebert at yourpants~videotron.ca> on 06-12-2000 08:16:29 AM Subject: [mg26251] [mg26247] Getting coordinates of array member Hi folks, Ok, let's say I have this 1 2 3 ----------- 1| 1 2 3 2| 4 5 6 3| 7 8 9 A 3x3 matrice or array. Each number in the array represents its' position from top left to bottom right. What I need to do is: Find what position 1,3 is. Just by looking at the array, we find that 7 is the answer. Find what are the coordinates of 7. Again just by looking at the array we see that the answer is 1,3 I need to come up with a simplu function that will return these. pos = GetPos(x,y) coord = GetCoord(pos) I've done this before, way long ago and can't find it. Thanks. -- Stephane Hebert ========================= stephhebert at yourpants~videotron.ca Remove yourpants~ to reply =========================