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

Home » Public Forums » archive » Re: Select values from one array that match multiple values from an other array
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: Select values from one array that match multiple values from an other array [message #82212] Fri, 30 November 2012 08:32 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Y

On Friday, November 30, 2012 10:15:28 AM UTC-5, PMagdon wrote:
> Dear all,
>
> I tried to use WHERE for multiple comparisons of two arrays.
>
> Here is a minimal example:
> 1.) Two arrays
> A=[1,3,2,5,2,6,1,9]
> B=[1,5]
> 2.) I need to extract all positions of A where any of the values from B occur in A. So that C should look like this:
> C=[0,3,6]

You can also try MATCH2 from the IDL astronomy library.
http://idlastro.gsfc.nasa.gov/ftp/pro/misc/match2.pro
This routine tells you which item in B matches A as well.
For example,

match2, a, b, suba
;; ---> [0L,-1L,-1L,1L,-1L,-1L,0L,-1L]
;; 0 1 2 3 4 5 6 7

indicates that A[0] matches B[0], A[3] matches B[1], and A[6] matches B[0]. You didn't actually ask for this level of information, but you can get what you want by using WHERE(SUBA GE 0).

Craig
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: need help with idl
Next Topic: Bug in STRMID system routine

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

Current Time: Wed Oct 08 17:03:42 PDT 2025

Total time taken to generate the page: 0.00790 seconds