X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 24 Jan 2007 04:47 AM by  anon
Array Manipulation
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
24 Jan 2007 04:47 AM
    i am new to IDL...so please help me with the doubt which i have mentioned below _____________________________________________ say an array a = [ 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 ] i would like to get a final array like this b = [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ] and not like this b= [ 0 0 0 1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 0 0 0 ]

    Deleted User



    New Member


    Posts:
    New Member


    --
    24 Jan 2007 04:47 AM
    The way to do this Sankar is to initialize an array of all 0's that has the final dimensions that you want and to then insert (like "pasting") your 'a' array at precisely the index where you want it to start overwriting your all-0's array. Thus: ; A simple, but tricky, way to make your 'a' array a = (indgen(9) + 1) # reform(intarr(5) + 1) endArray = intarr(9, 11) ; 9 columns by 11 rows of 0's endArray[0,3] = a ; pastes ALL of 'a' at that insertion point print, endArray, FORMAT='(9I3)' ; 0 0 0 0 0 0 0 0 0 ; 0 0 0 0 0 0 0 0 0 ; 0 0 0 0 0 0 0 0 0 ; 1 2 3 4 5 6 7 8 9 ; 1 2 3 4 5 6 7 8 9 ; 1 2 3 4 5 6 7 8 9 ; 1 2 3 4 5 6 7 8 9 ; 1 2 3 4 5 6 7 8 9 ; 0 0 0 0 0 0 0 0 0 ; 0 0 0 0 0 0 0 0 0 ; 0 0 0 0 0 0 0 0 0
    You are not authorized to post a reply.