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

Home » Public Forums » archive » Re: How to append a multi dimensional array?
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: How to append a multi dimensional array? [message #74251 is a reply to message #74248] Wed, 05 January 2011 04:04 Go to previous message
Brian Daniel is currently offline  Brian Daniel
Messages: 80
Registered: July 2009
Member
On Jan 5, 6:01 am, Balt <bindermue...@gmail.com> wrote:
> Hi all,
>
> a seemingly trivial problem and I can't get my head around it. Does
> anyone see the solution?
>
> Given:
> IDL> x = [1,2,3]
> IDL> y = [4,5,6]
> IDL> bigarray = [[x], [y]]
> IDL> help,bigarray
> BIGARRAY        INT       = Array[3, 2]
>
> Except, I can't do it like that, because I need to create BIGARRAY
> step by step, i.e. there are steps that require bigarray to already
> exist when y is calculated. And y then needs to be dynamically added
> to bigarray.
>
> How can I add a vector to an array generically? In "pseudo code", I
> need to be able to say bigarray[0] = x, then later bigarray[1] = y and
> so forth... all with dynamic (and automatic) resizing of bigarray, of
> course... :-)
>
> I suspect this is really simple and I've done similar things like
> adding a single element to an array dynamically ( array = [[array],
> newval] ) but this doesn't work when newval is a vector!
>
> Any hints greatly appreciated!
>
> - Balt

Part of the problem is how to concatenate arrays. Say your array is N
by M and you wanted to concatenate it with a vector such that it'll be
an N by M+1 array, then:

array = [[array],[reform(vector,N,1)]

Or, if the vector is of length M (column vector), then concatenating
to N+1 by M is:

array = [array,transpose(vector)]

Cheers,
Brian
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: stl files
Next Topic: Re: stl files

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

Current Time: Wed Oct 08 19:26:31 PDT 2025

Total time taken to generate the page: 0.00457 seconds