# findng array[3] in array[3,n]

• Subject: findng array[3] in array[3,n]
• From: "tbowers" <tbowers(at)nrlssc.navy.mil>
• Date: Thu, 25 Jan 2001 10:47:42 -0600
• Newsgroups: comp.lang.idl-pvwave
• Organization: Naval Research Laboratory, Washington, DC
• Xref: news.doit.wisc.edu comp.lang.idl-pvwave:23166

```If I have

a=[ \$
[0,1,2], \$
[3,4,5], \$
[6,7,8]]

b=[3,4,5]

how do I find where in a is the row vector b? The answer should
be 1, the 2nd row of a. I've tried many
permutations of where(), but I just don't get it. The only way I
can get an answer is to loop through the rows till i find a match.
What I'm really tryin' to do is to find a color in a color table,
where a color is. For the color that's listed 6th in the color table
(an almost black) that'd be the 5th row index. Like:

tvlct, r,g,b,/get
colorTable = transpose([[r],[g],[b]])  ;//a [3, 256] array
colorALMOSTBLACK=[22,0,9]
indexALMOSTBLACK=where(colorTable eq colorALMOSTBLACK)

What I want is the answer 5 because if you print the 1st 6 rows
of colortable you get:
print, colorTable[*,0:5]
0   0   0
4   0   3
9   0   7
13   0  10
18   0  14
22   0  19

I'm looking for that 6th row which is [22,0,9], my search array.

I've tried alot of different stuff, but i just don't get it
IDL> print, where(colorTable eq colorALMOSTBLACK)
1
IDL> print, where(colorTable[*,0:*] eq colorALMOSTBLACK)
1
IDL> print, where(colorTable[*,0:*] eq colorALMOSTBLACK[0:*])
1
etc., etc., etc....

So, does anyone know see an elegant solution to this problem??

tia,
tbowers

```