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

Home » Public Forums » archive » Dimensional confusion
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
Dimensional confusion [message #82116] Tue, 20 November 2012 05:54
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
Hi,
I was just trying to add an element to an array and got a bit confused with the dimensions. Therefore I wrote a post to ask for a solution and then feeling that the answer to the question couldn't be hard, I kept fighting for a solution until I got one... Therefore I'm posting question and answer. Now I'm maybe less confused about dimensions, but for sure more confused about the use of a group!

Say I construct an array as:

a = indgen(4,2)

and I want to add the element [0,0] at the end in order to have a 5x2 array.

The first solution I got was this (transpose-overdose):
b = transpose([[transpose([a])],[0,0]])
Then I tried to reduce the number of transpose and I got to this:
b = [[a],transpose([0,0])]
And then I told myself that there has to be a way to avoid that transpose function... and this was my solution:
b = [a,[[0],[0]]]

All these lead to the same answer:
IDL> help, a, b
A FLOAT = Array[4, 2]
B FLOAT = Array[5, 2]

Now the world seems fine again and I lost another half an hour to reinvent the wheel.

I thank groups.google for allowing some space to write some text and to think about what I just wrote.
Helder

PS: I hope some-where some-one finds this useful (also for teaching purposes as "what not to do")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: write to *.txt files
Next Topic: Curve Fitting Question

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

Current Time: Wed Oct 08 13:45:51 PDT 2025

Total time taken to generate the page: 0.00678 seconds