Re: how to convert a row of data in a column? [message #82904] |
Fri, 25 January 2013 09:01 |
Phillip Bitzer
Messages: 223 Registered: June 2006
|
Senior Member |
|
|
On Friday, January 25, 2013 7:57:04 AM UTC-6, pan...@gmail.com wrote:
> Thanks, I solved the problem myself by writing a for loop.
In IDL, for loops are the embodiment of pure evil:
http://www.idlcoyote.com/tips/forloops.html
Well, maybe not so bad sometimes:
http://www.idlcoyote.com/tips/forloops2.html
But, for your problem, you're trying to convert to a row vector into a column vector. A couple ways to that:
IDL> d = TRANSPOSE(set) & help, d
or
IDL> d = REFORM(set, 1, N_ELEMENTS(set))
|
|
|
|
Re: how to convert a row of data in a column? [message #82906 is a reply to message #82905] |
Fri, 25 January 2013 05:44  |
Mats Löfdahl
Messages: 263 Registered: January 2012
|
Senior Member |
|
|
Den fredagen den 25:e januari 2013 kl. 14:34:58 UTC+1 skrev pan...@gmail.com:
> I am using an external program which returns me a one dimensional array, .i.e. a row of data like this.
>
>
>
> 1 2 5 7 8 9 0
>
>
>
> The problem is that I need to read it as a column of data. I tried to create an array to store it but it doesn't work.
>
> (Here set=[1 2 5 7 8 9 0])
>
>
>
> d=dblarr(1,7)
>
> set=d
>
>
>
> but when I print set on the screen, it is still
>
> 1 2 5 7 8 9 0
>
> instead of
>
> 1
>
> 2
>
> 5
>
> 7
>
> 8
>
> 9
>
> 0
>
>
>
> what can I do?
>
>
>
> Many thanks
I'm not sure what lines you actually executed, because after the ones you posted both set and d should be a (1,7) array of zeros, which would print as a column and not as a row.
If you replace the set=d line with d[0]=set, the d vector should print as
IDL> print,d
1.0000000
2.0000000
5.0000000
7.0000000
8.0000000
9.0000000
0.0000000
|
|
|
|