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

Home » Public Forums » archive » Re: Extract Array positions for a set of Values
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: Extract Array positions for a set of Values [message #75434 is a reply to message #75427] Wed, 09 March 2011 06:37 Go to previous messageGo to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Wednesday, March 9, 2011 5:48:42 AM UTC-5, Paul Magdon wrote:
> Hi,
> have a quite simple problem for which I can find a fas solution:
>
> 1.) I have an IntArray A (e.g a result from LABEL_REGION)
>
> 1 1 1 1 0 0 0
> 1 1 1 1 0 0 2
> 0 0 0 0 9 0 2
>
> 2.) I have a vector B with Integers (e.g. 1,2,9)
>
> Now I want to extract the positions of B in A and set all values in A which are included in B to let's say 99. How can I do this without a loop?
> I tested HISTOGRAM(,REVERSE_INDICES) but as B is not consecutive (e.g 1,2,3,4) I can't find a solution.
>
> Cheers Paul

I'd try remapping the values so that B is consecutive, and then use value_locate (come on, you *knew* it was coming...) to figure out if it's in B or not.

b_sorted = b[SORT(b)]
locations = WHERE(b_sorted[VALUE_LOCATE(b_sorted, a)] EQ a, nlocations)
IF nlocations GT 0 THEN a[locations]=99

-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: LOADCT is not working
Next Topic: new COYOTE Graphics together with map_set

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

Current Time: Wed Oct 08 19:35:55 PDT 2025

Total time taken to generate the page: 0.00456 seconds