Re: ARRAYS [message #2854] |
Thu, 08 September 1994 08:45  |
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  |
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  |
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.
|
|
|