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

Home » Public Forums » archive » Re: How can I append a leading or trailing column to an existing 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 can I append a leading or trailing column to an existing array? [message #51352 is a reply to message #51348] Thu, 16 November 2006 13:52 Go to previous message
Benjamin Hornberger is currently offline  Benjamin Hornberger
Messages: 258
Registered: March 2004
Senior Member
willettk@gmail.com wrote:
> G'day,
>
> I'm looking for a quick (ie, one-line method) of appending a column
> vector to an existing array. As a simple example I would like to make:
>
> 1 1
> 1 1
>
> into
>
> 2 1 1
> 2 1 1
>
> I can think of a few ways to do it (one is listed below), but I would
> really like to do it using array concatenation. I've read a good
> tutorial about it at Coyote's website, but can't figure out the proper
> bracketing. Any ideas?
>

IDL> a=[[1,1],[1,1]]
IDL> print,a
1 1
1 1
IDL> b=[[2],[2]]
IDL> print,b
2
2
IDL> c=[b,a]
IDL> print,c
2 1 1
2 1 1


The key is creating b with the correct dimensions. Another option is

IDL> b=reform([2,2],1,2)
IDL> print,b
2
2

Cheers,
Benjamin
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: How can I append a leading or trailing column to an existing array?
Next Topic: Bitmap vectorization

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

Current Time: Wed Oct 08 18:27:00 PDT 2025

Total time taken to generate the page: 0.01138 seconds