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

Home » Public Forums » archive » 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
help with sorting vector elements in to subarrays [message #80234] Mon, 21 May 2012 07:33 Go to previous message
Tito is currently offline  Tito
Messages: 16
Registered: March 2012
Junior Member
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
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: help with mathematics
Next Topic: put a variable in 2D-array to plot a contour on a map.

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

Current Time: Wed Oct 08 15:06:47 PDT 2025

Total time taken to generate the page: 0.00462 seconds