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

Home » Public Forums » archive » Re: Finding duplicate values in an 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: Finding duplicate values in an array [message #2585 is a reply to message #2582] Tue, 19 July 1994 07:45 Go to previous message
slohmeie is currently offline  slohmeie
Messages: 2
Registered: July 1993
Junior Member
In article <1994Jul18.171646@chapman.gsfc.nasa.gov>,
Ian Sprod <sprod@chapman.gsfc.nasa.gov> wrote:
>
> I seem to remember the topic of finding duplicate values in an array
> was discussed some months ago, but i never did read the end of the thread.
>
> What is the _fastest_ way to throw duplicated values out?
>
> thanks
>
> ian

This is how I'd do it:

;array of values
arr = [.14, .11, .13, .12, .13, .13, .12, .13, .09, .13, .10, .12, .09, .14]

;sort array
arr_sorted = arr(sort(arr))

;find disparity between adjacent elements
n = n_elements(arr_sorted)
disparity = arr_sorted(1:n-1)-arr_sorted(0:n-2)

;find locations where disparities are non-zero
index = where(disparity)+1

;non-duplicated array
arr_nodups = [arr_sorted(0), arr_sorted(index)]

END

Hope this helps.
[Message index]
 
Read Message
Read Message
Previous Topic: JPEG reader?
Next Topic: Re: JPEG reader?

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

Current Time: Sat Oct 11 01:39:20 PDT 2025

Total time taken to generate the page: 0.48325 seconds