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

Home » Public Forums » archive » Re: adding "placeholders" to an 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: adding "placeholders" to an array [message #48969 is a reply to message #48968] Tue, 06 June 2006 14:53 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
pimpk24@hotmail.com wrote:
> Hello,
>
> I was wondering if there is a way to change the dimesions of an
> existing array and to hardwire the new values. It seems that the rebin
> and reform functions only add values by interpolation and nearest
> sampling. I want to predeterming what the new value will be
>
> e.g. Given a random vector, how can I add dimensions of all zero values
>
> 1 4 6 7 8 354 42345
> 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0
>
>
> thanks in advance
>

Brute force methods:


IDL> x=[1, 4, 6, 7, 8, 354, 42345]
IDL> n=n_elements(x)
IDL> print, [[x],[make_array(n,2,value=0)]]
1 4 6 7 8 354 42345
0 0 0 0 0 0 0
0 0 0 0 0 0 0

Or, you could use LONARR instead:

IDL> print, [[x],[lonarr(n,2)]]
1 4 6 7 8 354 42345
0 0 0 0 0 0 0
0 0 0 0 0 0 0

but the use of MAKE_ARRAY means you can change the "placeholder" value to something other
than zero if you wanted.

paulv

p.s. I'm sure there's a more elegant method than those above. :o)

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: .Reset_Session in a script
Next Topic: iTool identifiers

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

Current Time: Sat Nov 29 08:10:15 PST 2025

Total time taken to generate the page: 0.00896 seconds