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

Home » Public Forums » archive » Re: ARRAYS
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: ARRAYS [message #2854] Thu, 08 September 1994 08:45 Go to next message
saken is currently offline  saken
Messages: 6
Registered: November 1993
Junior Member
In article <34n95u$ise@hammer.msfc.nasa.gov>, mallozzi@ssl.msfc.nasa.gov writes:
|> I must be missing something simple, but I sometimes find myself needing to
|> concatinate arrays as follows:
|>
|> x = FINDGEN(10)
|> y = FINDGEN(4,20)
|> z = [x, y(1,*)]
|>
|> This won't work because IDL sees y(1,*) as a 2-d array, and x is 1-d.
|> Is there an easy way to concatenate two "vectors" without looping through
|> the y-array and extracting the approriate elements like this:
|>
|> (rest deleted)


Try using the REFORM function:

x = FINDGEN(10)
y = FINDGEN(4,20)
z = [x, REFORM(y(1,*))]

REFORM gets rid of dimensions where there is only one element of
the array.

jon
Re: ARRAYS [message #2855 is a reply to message #2854] Thu, 08 September 1994 12:10 Go to previous message
landers is currently offline  landers
Messages: 45
Registered: May 1993
Member
In article <34n95u$ise@hammer.msfc.nasa.gov>, mallozzi@ssl.msfc.nasa.gov writes:
|> I must be missing something simple, but I sometimes find myself needing to
|> concatinate arrays as follows:
|>
|> x = FINDGEN(10)
|> y = FINDGEN(4,20)
|> z = [x, y(1,*)]
|>
|> This won't work because IDL sees y(1,*) as a 2-d array, and x is 1-d.
|> Is there an easy way to concatenate two "vectors" without looping .....

Use REFORM, which will strip out those unity-dimensions:

z = [ x, REFORM( y(1,*) ) ]

--
;Dave
Re: ARRAYS [message #2858 is a reply to message #2854] Thu, 08 September 1994 11:06 Go to previous message
velt is currently offline  velt
Messages: 19
Registered: June 1994
Junior Member
> From mallozzi@ssl.msfc.nasa.gov
> I must be missing something simple, but I sometimes find myself needing to
> concatinate arrays as follows:
>
> x = FINDGEN(10)
> y = FINDGEN(4,20)
> z = [x, y(1,*)]

The simple answer is to reform the array you want to concatenate, that is,
to remove the extra dimensions:

IDL> x = FINDGEN(10)
IDL> y = FINDGEN(4,20)
IDL> z = [x,reform(y(1,*))]
IDL> help, z
Z FLOAT = Array(30)

Good luck,
Robert Velthuizen,
Digital Medical Imaging Program of the
H. Lee Moffitt Cancer Center and Research Institute at the
University of South Florida.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Problem with PLOT limits in IDL v3.6
Next Topic: Re: XYOUTS overwrites

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

Current Time: Wed Oct 08 16:01:20 PDT 2025

Total time taken to generate the page: 0.00385 seconds