X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 22 Jan 2008 08:26 AM by  anon
How to add rows and columns to an array.
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
22 Jan 2008 08:26 AM
    I like to add rows or columns of zeros to an existing array. The rows or columns will come at the beginning or end of the array and not in the middle. What is the easiest way to do this?

    Deleted User



    New Member


    Posts:
    New Member


    --
    22 Jan 2008 08:26 AM
    The real algorithm for this is: 1) Make a new array of the total finished size you want, followed by 2) "Paste" your current smaller array in the origin of the larger array. I.e. seed = 1L ; Make up a random "existing array" existingArray = randomu(seed, 16, 24) newArray = dblarr(32, 28) ; A 32 x 30 array of 0.0 doubles newArray[0,0] = existingArray That last call "pastes" your 'existingArray' into the first 16 columns and 24 rows of the 'newArray'. It is the equivalent of "newArray[0:15, 0:23] = existingArray", but is a more efficient syntax. James Jones
    You are not authorized to post a reply.