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

Home » Public Forums » archive » 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 #82479 is a reply to message #82218] Thu, 13 December 2012 10:24 Go to previous message
Sir Loin Steak is currently offline  Sir Loin Steak
Messages: 42
Registered: January 2012
Member
On Thursday, December 13, 2012 4:35:28 PM UTC, David Fanning wrote:
> 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.")


I was just about to post a question about this very topic - spooky! Would it also be possible to amend the SetDifference code so it also records positions, as I would like to know which elements of one array have no match in a different array.

Many thanks
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: array manipulation (TOTAL-ing or MEDIAN-ing) in uneven bins
Next Topic: Attempt to call undefined method: 'IDLITSYMBOL::IS3D'

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

Current Time: Wed Oct 08 17:02:50 PDT 2025

Total time taken to generate the page: 0.00366 seconds