[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*Subject*: Re: findng array[3] in array[3,n]*From*: JD Smith <jdsmith(at)astro.cornell.edu>*Date*: Thu, 25 Jan 2001 12:24:38 -0500*Newsgroups*: comp.lang.idl-pvwave*Organization*: Cornell University*References*: <94pl74$rec$1@ra.nrl.navy.mil>*Sender*: verified_for_usenet(at)cornell.edu (jts11 on vodka.tn.cornell.edu)*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:23171

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

**Follow-Ups**:**Re: findng array[3] in array[3,n]***From:*David Fanning

**References**:**findng array[3] in array[3,n]***From:*tbowers

- Prev by Date:
**Re: implicit loop.Reading of data** - Next by Date:
**Re: findng array[3] in array[3,n]** - Prev by thread:
**findng array[3] in array[3,n]** - Next by thread:
**Re: findng array[3] in array[3,n]** - Index(es):