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 #82480 is a reply to message #82215] Thu, 13 December 2012 08:35 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> OK, I just added a POSITIONS keyword to SetIntersection
> that will return the positions in vector A where the
> values in vector B appear.
>
> A=[1,3,2,5,2,6,1,9]
> B=[1,5]
> C = SetIntersection(a, b, Positions=pos)
> Print, pos
> 0 6 3

At Bob Stockwell's suggestion (and with his code!) I
have added the keywords INDICES_A and INDICES_B
to this program to allow you to return the matching
indices in BOTH vectors. Note that this assumes the
vectors A and B contain *unique* values. In other
words, INDICES_A and POSITIONS are identical vectors
IF vector A and B contain unique values. If they
don't, then POSITIONS will contain ALL of the locations
in vector A where the match occurs.

You can find the updated program here:

http://www.idlcoyote.com/programs/setintersection.pro

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
[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: Fri Oct 10 10:37:51 PDT 2025

Total time taken to generate the page: 1.60108 seconds