comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » findng array[3] in array[3,n]
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
findng array[3] in array[3,n] [message #23517] Thu, 25 January 2001 08:47
T Bowers is currently offline  T Bowers
Messages: 56
Registered: May 1998
Member
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,
e.g. load RAINBOW color table, (loadct,13) then identify
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:

loadct, 13
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
[Message index]
 
Read Message
Previous Topic: Lose control of IDL window
Next Topic: Re: implicit loop.Reading of data

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 05:34:03 PDT 2025

Total time taken to generate the page: 1.11779 seconds