Re: How do I add an array to the end of an existing array? [message #55072] |
Sun, 29 July 2007 12:44 |
MarioIncandenza
Messages: 231 Registered: February 2005
|
Senior Member |
|
|
On Jul 28, 12:00 am, snudge42 <snudg...@gmail.com> wrote:
> I want to do something which I'm sure is very simple. I have an array
> such as:
>
> 0 0
> 0 0
> 0 0
>
> and want to add a similar array to get
>
> 0 0
> 0 0
> 0 0
> 0 0
> 0 0
> 0 0
>
Note that for array operations, making examples with all zeroes is
likely to result in more confusion than not. Here's a relevant trick
to what I think your question was:
a=[[1,2],[3,4],[5,6]]
; this is one move:
print,rebin(a,2,6)
> 1 2
> 1 2
> 3 4
> 3 4
> 5 6
; this is another
print,[[a],[a]]
> 1 2
> 3 4
> 5 6
> 1 2
> 3 4
> 5 6
Note that your example with all 0's, could be satisfied by either of
these very different transforms.
Good luck,
Edward H.
|
|
|
Re: How do I add an array to the end of an existing array? [message #55083 is a reply to message #55072] |
Sat, 28 July 2007 05:48  |
Brian Larsen
Messages: 270 Registered: June 2006
|
Senior Member |
|
|
This is a good easy one and an important trick (way of thinking) to
learn.
IDL> a=[[1,1],[2,2],[3,3]]
IDL> print, a
1 1
2 2
3 3
IDL> b=[[4,4],[5,5]]
IDL> print, b
4 4
5 5
IDL> c=[[a],[b]]
IDL> print, c
1 1
2 2
3 3
4 4
5 5
Is this want you wanted?
Cheers,
Brian
------------------------------------------------------------ ---------------------
Brian Larsen
Boston University
Center for Space Physics
|
|
|