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

Home » Public Forums » archive » Re: help with sorting vector elements in to subarrays
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: help with sorting vector elements in to subarrays [message #80227 is a reply to message #80223] Mon, 21 May 2012 12:16 Go to previous messageGo to previous message
Russell Ryan is currently offline  Russell Ryan
Messages: 122
Registered: May 2012
Senior Member
On May 21, 10:33 am, Trifon Trifonov <tito_trifo...@abv.bg> wrote:
> Hallo!
>
> I have this vector:  zz = [5,6,9,10,11]
>
> Anybody can tell me how I can sort it like zz1 = [5,6], zz2 =[9,10,11]?
>
> Here is the code:
>
> zz =[]
> f=indgen(n_elements(amp))
>
> ;;I have amp[i] on witch some of the elements are identical.
> ;I need to take this [i]indexies and
> ;1-st to take it out
> ;2nd to write it to another array [sub arrays]
>
> for i=0L, n_elements(amp)-1 do begin
>  a = where(amp[i] eq amp ,count)
>  if count gt 0.0 then begin
>   if n_elements(a) gt 1 then begin
>     zz = [zz,i]
>   endif
>  endif
> endfor
>
> if n_elements(zz) ne 0.0 then begin
>  match2,f,zz,subf,subzz
>  f[subzz] = -1
>  f = f[where(f[*] NE -1)]
> endif
>
> zz = Long[5]
>            4           5           9          10          11
>
> f = Int[13]
>        0       1       2       3       6       7       8      12      13      14
>       15      16      17
>
> All the best,
> Trifon

You're not making much sense... How does zz=[5,6,9,10,11] sort into
zz1=[5,6] and zz2=[9,10,11]? Are you just taking the first two and
last three elements?

Russell

But, yes, uniq() is probably going to help you. Just remember, uniq
only works correctly on arrays which are sorted!
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: VM Save File Problem
Next Topic: Re: help with mathematics

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

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

Total time taken to generate the page: 0.80527 seconds