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

Home » Public Forums » archive » Re: 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 #49755 is a reply to message #49754] Tue, 15 August 2006 12:14 Go to previous messageGo to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Rick Towler wrote:
> I'm sure there is a built in function that I am unaware of but here is
> one way:
>
> b = a - shift(a,2)
> c = a[*, where(b[1,*] ne 0)]
>
> IDL> print, a
> 20.4000 30.2000
> 40.3000 60.2000
> 50.2000 32.4000
> 50.2000 32.4000
> IDL> b = a - shift(a,2)
> IDL> print, b
> -29.8000 -2.20000
> 19.9000 30.0000
> 9.90000 -27.8000
> 0.000000 0.000000
> IDL> c = a[*, where(b[1,*] ne 0)]

this seems to be incomplete...
you can have a value repeted in a column but not in another...
So you would have to get the indices on the 1st col and on the 2nd col.

IDL> a = transpose([[1,2,3,3,3],[5,5,4,4,1]])
IDL> print,a
1 5
2 5
3 4
3 4
3 1
IDL> b = a - shift(a,2)
IDL> c = a[*, where(b[1,*] ne 0)]
IDL> print,c
1 5
3 4
3 1

===>> 2;5 is missing!

so you should do
c = a[*, where(b[0,*] ne 0 or b[1,*] ne 0)]

IDL> print,c
1 5
2 5
3 4
3 1

we now have all entries..

Jean

> IDL> print, c
> 20.4000 30.2000
> 40.3000 60.2000
> 50.2000 32.4000
>
> -Rick
>
> Julio wrote:
>
>> 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
>>
[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: Re: File_COPY
Next Topic: SETENV

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

Current Time: Fri Oct 10 12:54:28 PDT 2025

Total time taken to generate the page: 1.12064 seconds