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

Home » Public Forums » archive » Removing equal elements from 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: Removing equal elements from an array [message #49831 is a reply to message #49761] Thu, 17 August 2006 09:07 Go to previous messageGo to previous message
news.qwest.net is currently offline  news.qwest.net
Messages: 137
Registered: September 2005
Senior Member
"Julio" <julio@cpa.unicamp.br> wrote in message
news:1155653196.084429.65000@74g2000cwt.googlegroups.com...
> Another question... please help me!!
>
> I have an array 'A' with two columns, latitudes and longitudes, and
> several lines. A need to make another array with the elements of A that
> don't repeat. An example:
>
> A[0]=[20.4, 40.3, 50.2, 50.2]
> A[1]=[30.2, 60.2, 32.4, 32.4]
>
> Note that the third and fourth pairs are the same (50.2, 32.4). So, I
> need to make another array and remove one of the pairs. So, I would
> have:
>
> A[0]=[20.4, 40.3, 50.2]
> A[1]=[30.2, 60.2, 32.4]
>
> Do you have any idea how to do that??
>
> Thanks!
>
> Julio

If I follow you correctly, you want to find unique pairs of numbers right?
How about combining the pairs into one number, and running uniq() on that?

For instance:

A = fltarr(2,4)
A[0,*]=[20.4, 40.3, 50.2, 50.2]
A[1,*]=[30.2, 60.2, 32.4, 32.4]
combo = A[0,*]*1000 + A[1,*]
indices = UNIQ(combo, SORT(combo))


{and of course, keep in mind the comments by JD and others about
using uniq on floats. You might want to change the lats and lon to integers
and then use uniq: (something like)
int_a = round(a*100)

Cheers,
bob
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: quickly reassign numbers in large array?
Next Topic: Re: Changing the Dec labeling from horizontal to vertical

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

Current Time: Fri Nov 28 22:49:44 PST 2025

Total time taken to generate the page: 1.04271 seconds