X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 03 Jul 2014 08:13 AM by  anon
Add values from sorted array to bigger unsorted array?!
 0 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
03 Jul 2014 08:13 AM
    So i have a little problem that i can't figure out on my own, which shouldn't be that hard i think :/ VEC_1 VEC_2 X 1 11 X1 2 22 X2 VEC_1 VEC_2 X 1 11 X1 2 22 X2 2 22 X2 1 11 X1 0 0 0 i have the sorted array and want to add the values into the unsorted array(red). The sorted array is about 500000 rows and the unsorted is about 900000 rows including non importand values i want to keep. I tried with differnt methods but never made it. 1. WHERE: ARR_unsorted[where(sorted_arr(0,*) EQ unsorted_arr(0,*))]=sorted_arr 2. FORFORIF: a double for loop for each size of the vector and if the values are the same place the right values 3. FOREACH: foreach element, sorted_arr(0,*) do begin $ if unsorted_arr(element) then unsorted_arr=[unsorted_arr,elemnt] none of these worked but i am sure it has to be possible somehow. thanks in advance Update: Vec_1 is a time vector and so is VEC_2, but in a different reference. X are interpolated coordinates corresponding to Vec_2. I have a Grind in the Vec_1 time reference and want the the same grind for Vec_2 and X. SOLVED! Ok i finally made it! It takes extremely long, but right now i really don't care, maybe i'll try some different method in the futur. I'll post my code here if someone needs something similar. for j=0,N_ELEMENTS(ARR_UNIQ(0,*))-1 do begin print, j foreach i, ARR_UNUNIQ(0,*), key do begin if ARR_UNUNIQ(0,key) EQ ARR_UNIQ(0,j) then begin ARR_UNUNIQ(1:*,key)=ARR_UNIQ(*,where(ARR_UNIQ(0,*) EQ ARR_UNIQ(0,j))) endif endforeach endfor
    You are not authorized to post a reply.