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

Home » Public Forums » archive » Re: array concatenation in 2-D
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: array concatenation in 2-D [message #59622] Fri, 04 April 2008 14:25 Go to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On Apr 4, 3:31 pm, Jean H <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
> elwood wrote:
>> I have a loop which calculates two variables x[i] and y[i]
>
>> At each iteration of the loop I calculate
>> x and y
>> And I'd like to concatenate x and y into a 2 column, unknown numbers
>> of rows
>> output array.
>> I'd like to dynamically grow the output array at each interation.
>
>> For example:
>> x=1 y=5 on first iteration
>> x=2, y=6 on 2nd iteration
>> I want an output array that looks like the below:
>
>> 1 5
>> 2 6
>
>> How do i achieve this without knowing the array size??
>
>> Tx!
>> -Elisha
>
> Elisha,
> You can concatenate the arrays, as you suggest:
>
> a = [[1,2],[3,4]]
> a = [[a],[5,6]]
> help,a
> ==>A INT = Array[2, 3]
>
> However, if you have many elements, this can be very resources
> consuming. Another option is to create a "big" 2*n array, to
> progressively fill it, to keep a counter on the number of entries, and
> finally to cut what you haven't used.... and similarly, if your array is
> not big enough, add a large number of rows and keep filling them (use
> the same concatenation method as above)
>

Hi,

As a second to the method jean suggests, you might want to consider
using Mike Galloy's collections objects which are efficient resizable
buckets for holding data. Check it out at ...

http://michaelgalloy.com/2006/04/24/collection-package-mgarr aylist.html

Cheers,
Ben
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: No removal of "NaN" while plotting on both PLOT and iPLOT
Next Topic: Re: Tilde with IDL

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

Current Time: Fri Oct 10 16:28:58 PDT 2025

Total time taken to generate the page: 0.80016 seconds