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

Home » Public Forums » archive » Re: Removing repeating array 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: Removing repeating array values [message #48104 is a reply to message #48103] Tue, 28 March 2006 12:43 Go to previous messageGo to previous message
savoie is currently offline  savoie
Messages: 68
Registered: September 1996
Member
David Fanning <davidf@dfanning.com> writes:

> Jonathan Wolfe writes:
>
>> Is there an easier way than a for loop to remove repeating values
>> within an array? For example, I have two arrays and am trying to match
>> the closest value from one with the other using a where() statement.
>> When the where statement is returned, I have multiple instances of the
>> same value; however, I just want to keep one of these. A for loop
>> works, but computing speed is slow, I'm running on an old 700MHz PIII.
>> Do you know of a faster way? Thanks for the help!
>
> Removing elements from an array is tailor-made for
> the HISTOGRAM function. See the Histogram Tutorial for
> an example:
>
> http://www.dfanning.com/tips/histogram_tutorial.html
>
> Cheers,
>
> David


I responded privately at first, but thought other people might want this too.


Is UNIQ what you're looking for?
from the manual...
; Create an array:
array = [1, 2, 1, 2, 3, 4, 5, 6, 6, 5]

; Variable B holds an array containing the sorted, unique values in
; array:
b = array[UNIQ(array, SORT(array))]
PRINT, b
IDL prints

1 2 3 4 5 6



It might be faster than learning histogram :)

Just a thought.

Matt


--
Matthew Savoie - Scientific Programmer
National Snow and Ice Data Center
(303) 735-0785 http://nsidc.org
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Removing repeating array values
Next Topic: Re: problem using p.multi in IDL 5.3/IRIX

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

Current Time: Fri Oct 10 04:28:14 PDT 2025

Total time taken to generate the page: 7.36549 seconds