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

Home » Public Forums » archive » Re: 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
Re: findng array[3] in array[3,n] [message #23513 is a reply to message #23510] Thu, 25 January 2001 09:24 Go to previous message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
tbowers wrote:
>
> 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:

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

I can't say it's elegant, but:

where(total(rebin(b,n_elements(b),(size(a,/DIMENSIONS))[1],/ SAMP) eq
a,1) eq n_elements(b))

The rule is, when comparing arrays, you must expand the smaller to the
size of the larger.

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: colors... again
Next Topic: Re: Back to idl after a looong time...

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

Current Time: Sat Oct 11 11:36:06 PDT 2025

Total time taken to generate the page: 0.79931 seconds